Jump to content

Follower Sitter Bummer!


Karlos Zero
 Share

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

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

Recommended Posts

Hi everyone,

I am working on a script for a saddle sitter for avatars, and I managed to make the saddle move and turn, but once another avatar sits on it, the turning function stops completely.
Not sure why since I am not an expert scripter, but I am sure I overlooked something. Will paste my script here and let me know your thoughts on the topic.

rotation Turn;
default
{
    state_entry()
    {
        llSetTimerEvent(0.5);
        llSensorRepeat("", NULL_KEY, AGENT, 5, PI,0.5);
        llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
    }

    timer()
    {
        
        vector OFFSET = <0,0,2>;
        vector OwnerPos = llList2Vector(llGetObjectDetails(llGetOwner(), [OBJECT_POS]),0) + OFFSET;

        llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POSITION, OwnerPos]);
        llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_ROTATION, Turn]);
    }
    sensor(integer num_detected)
    {
        Turn = llDetectedRot(0); 
    }
}

Link to comment
Share on other sites

llDetectecRot(0) in the sensor event will return the nearest avatar. That would be the one sitting on the object I guess.

You could also get the rotation from the owner with llGetObjectDetails. Doing a llVecDist check for the 5 meter range as well could make the sensor obsolete entirely.

Link to comment
Share on other sites

1 hour ago, Rolig Loon said:

Your sensor will fail the instant that you are seated.  At that point, you become a link in the seat's linkset, and an object cannot sense itself.

I don't think that this is true actually. In that case Karlos script would have work (at least to some degree), because it would still get another avatar than the one which is nearest, the one sitting on the saddle.

If I understand the purpose of this follower correctly, the saddle is meant to follow one avatar, which is the owner of the saddle as well, and a second avatar is just sitting on the saddle, riding the saddle owners avatar.

Link to comment
Share on other sites

Oh, I didn't mean to imply that that's the only limitation, but it is a real one.  The LSL wiki has a note to that effect:

"Objects do not detect themselves, and attachments cannot detect their wearers (this includes HUD attachments)."

and I've run into that problem many times.  So, your earlier comment that " the sensor event will return the nearest avatar. That would be the one sitting on the object I guess. " won't wash.  My guess is that the sensor's range is just too short to detect the nearby av.

Link to comment
Share on other sites

No, it's not.  "Sitting" is linking yourself to another object, where you become the highest numbered link in the linkset.  That object, which is the one that contains the sensor, cannot detect itself or any part of itself -- you.

Edited by Rolig Loon
Link to comment
Share on other sites

Give it a shot when you are in-world. :)

default
{
    state_entry()
    {
        llSitTarget(<0.5, 0.0, 0.5>, ZERO_ROTATION);
        llSensorRepeat("", "",AGENT,5.0, PI, 2.0);
    }
        
    sensor(integer num_detected)
    {
        llOwnerSay(llKey2Name(llDetectedKey(0)));
    }
} 

 

Link to comment
Share on other sites

Hi and thanks for the reply everyone!

Arton's suggestion worked well. Since the object I am working on should detect the owner, I made the sensor filter that and thus it was resolved now the rotation worked well.
Thanks for all the support!

Just for clarification, the object is meant to be sat on by another avatar not the owner.

Edited by Karlos Zero
Link to comment
Share on other sites

@Karlos Zero The following script will do exactly the same as yours, but without a sensor. Just a suggestion.

default
{
    state_entry()
    {
        llSetTimerEvent(0.5);
        llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
    }

    timer()
    {        
        vector OFFSET = <0,0,2>;
        list lGOD = llGetObjectDetails(llGetOwner(), [OBJECT_POS, OBJECT_ROT]);
        vector OwnerPos = llList2Vector(lGOD, 0);
        if (llVecDist(OwnerPos, llGetPos()) <= 5.0) 
        {
             llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POSITION, OwnerPos + OFFSET, PRIM_ROTATION, llList2Rot(lGOD, 1)]);
        }
    }
} 

 

Edited by arton Rotaru
  • Like 3
Link to comment
Share on other sites

I was thinking it was a saddle to wear, I just wasn't sure and didn't want to open my mouth and look foolish... I forget sometimes how many people in SL are into playing horsey... xD

I can think of other uses for the same stuff, too, like a piggyback baby carrier, etc. This is a good thread, IMO. ^-^

Edited by Berksey
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2533 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...