Jump to content

Writing a faster llMoveToTarget that does not require object to be physical


VirtualKitten
 Share

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

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

Recommended Posts

Hi everyone ,

I wonder if any of you can help I needed a faster version of the follow-me scripts available all using  llMoveToTarget that require the item to be physical . I am there for trying to get something else to work and having a bad day My object will rotate the same as me but not to the offset position can anyone help? .I have read you should not use sensor something to do with Havock
 

Thanks for looking I hope you are all well

Link to comment
Share on other sites

This example on LlSetKeyFramedMotion does just that. It does use a sensor, but you could easily change it to a timer that polls for the position and rotation of the avatar/object it's following. The benefit of the timer is you could get that info from across the sim and at a much larger height, rather than the limit of 96m in the sensor

Edited by Ruthven Ravenhurst
Link to comment
Share on other sites

@Ruthven RavenhurstHi and thanks for that link its very kind I have seen it but I was writing something smaller that isn't quite working  strangely it does the same as mine using the Sample Script - Key Framed Follower it rotates but does not come close I haven't figured out what is going on :

//Follower script originally from wiki modified to run faster.

vector offset = < 0, .25, 0>;  //1 meter behind and 1 meter above owner's center.
key l_myowner = "c14f48db-464c-4ccb-af11-8b58e78d6aa0";
default
{
    state_entry()
    {
        llSetStatus(STATUS_PHYSICS, FALSE);
        // Little pause to allow server to make potentially large linked object physical.
        llSleep(0.1);
        llSetTimerEvent(1.0);
    }
    timer()
    {
        list det = llGetObjectDetails(l_myowner,[OBJECT_POS,OBJECT_ROT]);
        vector pos   = llList2Vector(det,0);
        rotation rot = llList2Rot(det,1);
        vector worldOffset = offset;
        vector avOffset = offset * rot;
        pos += avOffset;       // use the one you want, world or relative to AV.
       // llMoveToTarget(pos,0.1);
       llSetPrimitiveParams([PRIM_POSITION,pos,PRIM_ROTATION,rot]);
    }
}

It does rotate but cant seem to get it to move for some reason . But having a bad day so have given up with it for today as sometimes things get easier with a break :)

 

Hugs D x

Edited by VirtualKitten
changed code as suggested
Link to comment
Share on other sites

If you're trying to change position by more than 10  metres no movement is likely, how far away is your target?

 

In your example keyframed motion would be quite easy, you have a destination vector and from that you can derive the delta vector by simply subtracting llGetPos(), apply the rotation first, then waddle over using the delta vector and KFM_TRANSLATE.

Just out of curiousity, after you use llList2Vector to get pos, why do you not use llList2Rot to get the rotation but instead extract it as a string and cast that to a rot?

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

All the functions that use PRIM_POSITION do kinematic (non-physical) motion, same as llSetPos and llSetRegionPos. Personally, I'd use llSetRegionPos in this case, so the follower can get anywhere in the sim with just one hop. I did a quick test and the script works as-is, but I'm not sure what the actual objective is here. "Faster" would require a tighter timer interval, which is of course laggier the shorter the interval. That lag might be reduced some by checking that each new position is far enough away from the last moved-to position to be worth moving the object, forcing an update to every viewer in sight.

Link to comment
Share on other sites

vector offset = < 0.2, 0.2, 0.2>;  //1 meter behind and 1 meter above owner's center.
key l_myowner = "c14f48db-464c-4ccb-af11-8b58e78d6aa0";
default
{
    state_entry()
    {
        llSetStatus(STATUS_PHYSICS, FALSE);
        // Little pause to allow server to make potentially large linked object physical.
        llSleep(0.1);
        llSetTimerEvent(1.0);
    }
    timer()
    {
        list det = llGetObjectDetails(l_myowner,[OBJECT_POS,OBJECT_ROT]);
        vector pos   = llList2Vector(det,0);
        rotation rot = llList2Rot(det,1);
        vector avOffset = offset *rot;//*llEuler2Rot(<0,0,-90>)*DEG_TO_RAD;
        pos += avOffset;       // use the one you want, world or relative to AV.
       // llMoveToTarget(pos,0.1);
       llSetPrimitiveParams([PRIM_POSITION, pos/*, PRIM_ROTATION,rot*/]);
    }
}

 

Got it moving but how do i get it to face to the same direction as me it was moving with particle shooting out the front now it doesn't do that

Edited by VirtualKitten
Link to comment
Share on other sites

41 minutes ago, Qie Niangao said:

Oh, not if it's physical. That'll never work, sorry if I somehow suggested it would. (I guess my "as-is" was referring to a later version that turned physics off.)

had me thinking that was something new that I missed and would like to have. Dang!

Link to comment
Share on other sites

I mean, the code that's posted at the moment has the PRIM_ROTATION parameter commented out, so it would hardly be surprising that's not rotating. Otherwise, it would rotate to face the same direction as the avatar it's following (modulo whatever animations make that avatar appear rotated differently). That is to say, it's simply using the avatar's own rotation, so it won't face toward the avatar. (Well, in the case of an offset that's behind the avatar, facing the same direction as the avatar would be facing toward the avatar's back.)

If it's instead supposed to be facing toward the avatar, two alternatives come to mind. One would be to calculate the rotation based on the relative positions, and the second would assume offset is a constant so then a corresponding constant rotation could be applied on top of the avatar rot. (So in the above-noted special case of following from behind, that additional constant rotation would be ZERO_ROTATION; if instead the offset keeps the follower directly in front of the agent, that would be llEuler2Rot(<0,0,PI>) - to face exactly the opposite direction of rot, thus looking back at the avatar.)

Link to comment
Share on other sites

Denise, am not sure where you are with the code

as wrote

llSetStatus(STATUS_PHYSICS, FALSE);
llSetPrimitiveParams([PRIM_POSITION, pos, PRIM_ROTATION,rot]);

follows and orients the follower to face the same direction as the avatar

if the particle emitter stream is not going in the direction you want then depending on the method used to emit the particles, either re-orient particle direction in the particle system, or rotate the follower as Qie mentions

Link to comment
Share on other sites

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