Jump to content
KiondraeLoc

Fix Camera Lock to Object

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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
14 minutes ago, steph Arnott said:

What does this do?


listen(integer channel, string name, key id, string message)
    {
        if(llGetPos())

Literally?  It says, "If my present location is not <0,0,0>, go ahead and do stuff ..."

Share this post


Link to post
Share on other sites
Just now, Rolig Loon said:

Literally?  It says, "If my present location is not <0,0,0>, go ahead and do stuff ..."

But what is the point? Maybe i am half asleep because i just do not get it.

Share this post


Link to post
Share on other sites
Just now, steph Arnott said:

But what is the point? Maybe i am half asleep because i just do not get it.

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

Share this post


Link to post
Share on other sites
7 minutes ago, Rolig Loon said:

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

The odds of that are higher than you being the first woman on the moon.

  • Haha 1

Share this post


Link to post
Share on other sites
Posted (edited)
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

Share this post


Link to post
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.  😉

Share this post


Link to post
Share on other sites
Posted (edited)
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...