Jump to content

Follow script that maintains position


Guest
 Share

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

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

Recommended Posts

Hello folks,

I am looking for a follow script. I have tried a couple using either llMoveToTarget or llSetPosition but they are too laggy, in the sense that they take a long time to move to a new position. I need one that will keep up with me as I am walking along and maintain a fairly constant position from the avi. Any ideas?? 

Link to comment
Share on other sites

Wear the object instead of having it follow you, it's much simpler all around.  Otherwise, if you are 'looking for a follow script' instead of wanting to write one, try the wanted forum or, to hire someone to write it for you, in-world employment.

llMoveToTarget(), llSetPos() and llSetKeyframedMotion() are pretty much it for relocating an object.  Making them move more quickly/more often means sensing you more frequently, so more lag.  You also have to consider the minimum event delay, etc.

Link to comment
Share on other sites

Take a good look at this thread >>> http://community.secondlife.com/t5/LSL-Scripting/Trying-to-make-an-object-follower/td-p/1354695  The OP was trying to solve almost exactly the same problem --- a very smooth, rideable follower that uses llSetKeyframedMotion.  We managed to get it to work quite well, and I have used the solution myself a couple of times since.

Link to comment
Share on other sites

Thanks for the suggestion but I have already tried the free scripts and they don't keep up, they drop behind and then catch up. This doesn't fit my requirement.

I think that I am going to need some sort of vehicle script. I tried a motorbike script but kept on crashing. LOL. I think a vehical script that works with a walking animation, but I haven't found one yet.

Link to comment
Share on other sites

Another possibility is llPursue() which is going to be rolled out to the main grid before too long (already beta testing on Agni is taking place), which is specifically designed to intellegently path from where the object is to where the target object is.  llPursue() avoids dynamic objects like avatars and moving objects, and will intelligently avoid collision with all objects static or dynamic.

Link to comment
Share on other sites

Thanks again Rolig, it works great. There is a bit of judder but it is fine for my purposes. I changed the script so that it would follow me, changed the offset so that it was in front of me and a bit higher. I had to tweak the timing to avoid the delta time error. So for anyone else that is interested in an alternative 'follow me' script this is what I ended up with:

 

 

//Ref: http://community.secondlife.com/t5/LSL-Scripting/Trying-to-make-an-object-follower/td-p/1354695key mykey;rotation NormRot(rotation Q){    float MagQ = llSqrt(Q.x*Q.x + Q.y*Q.y +Q.z*Q.z + Q.s*Q.s);    Q.x = Q.x/MagQ;    Q.y = Q.y/MagQ;    Q.z = Q.z/MagQ;    Q.s = Q.s/MagQ;    return Q;}    integer gON;default{    state_entry()    {        mykey = llGetKey();        llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_CONVEX]);     }        touch_start(integer total_number)    {        gON = !gON;        if (gON)        {            llSay(0,"Switch ON!");//          llSensorRepeat("","91b39b5b-13b1-2517-273a-67360b842c02",SCRIPTED,10.0,PI,0.1); //Following my scripted vehicle            llSensorRepeat("","myKey",AGENT,15.0,PI,0.11); //Following me        }        else        {            llSensorRemove();        }    }        sensor(integer num)    {//      llSetKeyframedMotion([(llDetectedPos(0) - llGetPos()) + *llDetectedRot(0), NormRot(llDetectedRot(0)/llGetRot()),0.11],[]);        llSetKeyframedMotion([(llDetectedPos(0) - llGetPos()) + *llDetectedRot(0), NormRot(llDetectedRot(0)/llGetRot()),0.12],[]);    }}

 

 

Link to comment
Share on other sites

Thanks for that suggestion Johan, I may try that option as well. But if it needs a path it wouldn't work because I want to use this on other peoples sims as well as my own. Anyway that is a bundle of tricks that I will be exploring for sure.

Link to comment
Share on other sites

Fantastic.  I'm glad it worked for you.  llSetKeyframedMotion is definitely one of the nicest functions we have gained in LSL recently.  There's only one rather small change I'd recommend in your script.  You define the variable mykey and then assign it the value of the object's UUID.  It should be your own UUID, since the object is supposed to be following you, not itself.  Probably the easiest way to rectify that is to get rid of mykey altogether and just write

llSensorRepeat("",llGetOwner(),AGENT,15.0,PI,0.11); //Following me
Link to comment
Share on other sites

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