Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Prim to follow the perimeter of the SIM Script?

Kerri Macchi
Registered User
Join date: 28 May 2008
Posts: 3
01-09-2009 04:58
Hi All

I am trying to script an object (which will later become a train / from of transport) which allows avatars to sit on it whilst it brings them around the perimeter.

I have scripted an object using LLMoveToTarget, but I would ideally like a smooth movement and the ability for the object to recognise turns in the SIM.

I have added the script I’m working of – if anyone could help me out on this I’d be very grateful.

Kerri


------------------------------


integer targetID;
default
{
touch_start( integer total_number )
{
llSetStatus(STATUS_PHYSICS, TRUE);
vector destination = llGetPos() + <-50, 0, 0>;
float range = 0.5;
targetID = llTarget( destination, range );
llMoveToTarget( destination, 10 );
}
not_at_target()
{


}
at_target( integer number, vector targetpos, vector ourpos )
{
llTargetRemove(targetID);
llStopMoveToTarget();
llSetStatus(STATUS_PHYSICS, FALSE);

}
}

------------------------------
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-10-2009 09:46
A train might get awfully heavy for the normal physical movement functions like llMoveToTarget(). I'd suggest using the actual vehicle functions. Rather than control inputs, just use autopilot type logic like you would with llMoveToTarget(). The big difference is that you have to use relative velocities (i.e. start turning to the left and wait until you're pointing in the direction you want) rather than absolute positions and directions (i.e. point THIS way).

Best vehicle "tutorial"/guide I've run into: http://www.lslwiki.net/lslwiki/wakka.php?wakka=TutorialVehicle
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-10-2009 10:52
llSetPos works better for large set course transits in my experience... but requires preset stops coordinates for stops and turns.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-10-2009 10:58
From: Void Singer
llSetPos works better for large set course transits in my experience... but requires preset stops coordinates for stops and turns.

Could be. I created one of those for a sim owner once. It worked well, but keep in mind things like:

1.) All passengers MUST sit down.
2.) Can take up LOTS of script time if you want the movement to be really smooth, so make sure the owners/managers of the sim are willing to make that tradeoff.
3.) Smooth IS relative, and what appears smooth on one viewer may not be very smooth on another. Also, there can be little hiccups--especailly when time dilation is low--that can cause strange looking behavior.

It can be one of the more..stable...solutions though. Maybe it is different these days (esp. with Havok 4), but in the past physical objects/vehicles could get stuck after operating for a while with no one around. Sometimes to the point of needing to be manually reset (though often little hacks like setting the object non-physical then physical again could do it).