Jump to content

Fix Camera Lock to Object


KiondraeLoc
 Share

You are about to reply to a thread that has been inactive for 1492 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

This is the script I have in my hud:

string TargetName = "n";
default {
    
    state_entry() {
        // run this code when entering the default state
        // displays red "OFF" as floating text above the prim
        llRegionSay(3, "off");
        llSetText("OFF", <1,0,0>, 1.0);
        llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA);
 llClearCameraParams();
  llSetTimerEvent(0.0);
    }
    touch_start(integer num_detected) {
        // when touched, switch to state named 'on'
        state on;
        llRegionSayTo("n", 3, "on");
    }
     }    
        
      
    

 
state on {
    state_entry() {
       
        llRegionSay( 3, "on");
        // run this code when entering state 'on'
        // displays green "ON" as floating text above the prim
        llSetText("ON", <0,1,0>, 1.0);
            llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA);
 llSetTimerEvent(0.022);
  llListen(4, "","", "");
  
 
 }
  

    touch_start(integer num_detected) {
        // when touched, switch to the default state
        state default;
    
    }
    listen(integer channel, string name, key id, string message)
    {
        if(llGetPos())
        {
           list data = llGetObjectDetails(TargetName, [OBJECT_POS, OBJECT_ROT]);
        vector pos = llList2Vector(data, 0);
        rotation rot = llList2Rot(data, 1);

        llSetCameraParams([
            CAMERA_ACTIVE, TRUE,
            CAMERA_FOCUS_LOCKED, TRUE,
            CAMERA_POSITION_LOCKED, TRUE,

            CAMERA_FOCUS, pos, 
            CAMERA_POSITION, pos + (<0, -2, 1> * rot)  
        ]);
        }
    }
    

}

This is the script I have in my RC Flying Drone: 


string TargetName = "n";
default{
    on_rez(integer r){
        llResetScript();
    }
     state_entry()
    {
        llListen(3, "","", ""); 
    }
    listen(integer channel, string name, key id, string message)
    {
         if (llGetOwner() != llGetOwnerKey(id))
        {return;}
        
        if(message == "on")
        {
             
          llSetTimerEvent(0.05);
        }
          
        if (message == "off")  
        {
            llSetTimerEvent(0.0);   
        }
        
        }
 timer()
    {
      
  llSetObjectName(TargetName);     
        llRegionSay(4,(string)llGetPos());
    }
}

How can I get the camera to track the object and not the bottom left corner of the sim at <0,0,0>? I don't want to use the object uuid, I want to use the name of the object to track on a channel so I don't have to keep changing the uuid of my object every time I rez it.

Link to comment
Share on other sites

I'm not quite sure what you are asking for, but when I design something like this, I make the HUD be the rezzer that generates the drone.  That way, I automatically know the UUID of the drone as it is created, from the result of an object_rez event.

  • Like 2
Link to comment
Share on other sites

12 minutes ago, Rolig Loon said:

I'm not quite sure what you are asking for, but when I design something like this, I make the HUD be the rezzer that generates the drone.  That way, I automatically know the UUID of the drone as it is created, from the result of an object_rez event.

Am somewhat confused at the OPs request myself seeing as that is what the object_rezz event is for.

Link to comment
Share on other sites

13 minutes ago, Rolig Loon said:

Oh, I have no idea. Personally, I would not want a HUD that only works if I happen to NOT be standing at <0,0,0>.

Which is pretty much anywhere.

I think the OP misunderstands llGetPos() as being the position of the drone, relayed to the HUD via llRegionSay in the timer event. The HUD's listen event makes no reference to the message it receives, and the only thing the drone says is its position. If the HUD were actually looking at the message, I don't think the OP would be asking this particular question.

Edited by Madelaine McMasters
Link to comment
Share on other sites

10 minutes ago, Madelaine McMasters said:

I think the OP misunderstands llGetPos() as being the position of the drone, relayed to the HUD via llRegionSay in the timer event. The HUD's listen event makes no reference to the message it receives, and the only thing the drone says is its position. If the HUD were actually looking at the message, I don't think the OP would be asking this particular question.

Yup, and I was hoping that the OP would figure that out for herself.  😉

Link to comment
Share on other sites

3 hours ago, Madelaine McMasters said:

Which is pretty much anywhere.

I think the OP misunderstands llGetPos() as being the position of the drone, relayed to the HUD via llRegionSay in the timer event. The HUD's listen event makes no reference to the message it receives, and the only thing the drone says is its position. If the HUD were actually looking at the message, I don't think the OP would be asking this particular question.

Would make more sense doing this.

listen(integer channel, string name, key id, string message)
    {
        if(name == "whatever_it_called")
        {
            llOwnerSay( (string) id );//use this data for whatever purpose. Make it a global variable if you want to.

        }
    }

 

Edited by steph Arnott
data collection output.
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1492 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...