Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need a tiny bit of help with SetPos

Paul Llewelyn
Registered User
Join date: 9 Jul 2004
Posts: 86
08-11-2006 10:02
I am not a super scriptor but I do need a tiny bit of help with a project I have in mind.

I want to create a SLOW moving vehicle that follows a specific path around a sim and I am getting bolloxed up using a series of SetPos calls. The vehicle prim is shooting fast to the new location. So what I need to know is if there is a way to control the speed at which the prim moves to the next position?
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-11-2006 13:02
You have two choices:

1.) Make the vehicle physical and use 'llMoveToTarget()' or other physical movement functions.

2.) Use 'llSetPos()' in very small steps to incrementally move toward the destination. To REALLY make this smooth you need worker scripts to overcome the 0.2 second script delay (they really need to get rid of the mandatory delays; I'll bet anything that it only winds up causing more lag than allowing frequent calls would, since people just run tons of non-stop scripts to work around the problem).
Grazel Cosmo
Registered User
Join date: 12 Mar 2005
Posts: 28
08-11-2006 13:03
With SetPos it instantly moves to the new spot up to 10m away (if the destination in SetPos is more than 10m it will stop at 10m). If you want it to move slow you will want to use small increments for SetPos and maybe a sleep of 1 second or a small for count loop if you want it to pause less than 1 second.

You'll want to figure out the current position, the waypoint (each spot it needs to turn to head a different way), and the offset/direction between current position and the waypoint. Then have SetPos move the object a small incrment towards the waypoint (say .1m or so). Get its new position for the next step, and have the script sleep for 1s (or set a 1s timer event) or use a for loop that just counts or some low overhead function that delays a script for a period of time (many delay the script by .2 or .4 seconds) before it makes the next step towards the way point.

This is about your only option to use if the object can't be set physical since SetPos is fairly instant and can't be given a velocity (if the sim is laggy a SetPos movement will go slower though due to script time slices).
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-11-2006 13:56
Oh, BTW, this vehicle will pass right through any avatars in the way without a collision (though if the avatars themselves move it could possibly trigger one). Just so's you know.