Making a sled, and respawning objects
|
|
Seven Shikami
Registered User
Join date: 22 Sep 2006
Posts: 82
|
04-25-2007 18:08
Two script puzzles I could really use some help on.
I'm making a waterslide. The idea is you'll sit on a raft, which starts out non-physical, but then turns into a vehicle and gets some forward momentum going. It slides down the track, twisty turny, until at the other end it collides with something that'll order it to die. Meanwhile, a respawner listens for the object to channel-announce its previous position and rotation, wait a few seconds, and spawns a new one for the next slider to use.
It works. Except for two things.
One, with an avatar sitting on it, the sled is topheavy. It banks hard on the first turn, tumbles over the side and "hooks" the avatar there sitting in the L shape (with legs out; it's a custom animation I made). How do I disable rolling along the X axis for the vehicle?
Two, when the sled announces is position using llGetPos, as near as I can tell (since it checks its position BEFORE someone sits on it and thus the avatar shouldn't affect it) it's getting the world coordinates of the root prim... not the actual center of the object. So when it rezzes the new sled, it's up and back a little bit more than it should be. How do I compensate? I'm guessing Bounding Boxes but I can't figure out how to apply it.
Any help welcome!
|
|
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
|
04-25-2007 19:00
Been a while since I've messed with vehicles, but for what it's worth: 1) I think what you want to mess with is VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY and VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, these affect how strong and fast-acting the force is that makes a vehicle tend to want to stay upright. Alternatively you could try llSetStatus(STATUS_ROTATE_X, FALSE) http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetStatusbut I don't know if you can expect predictable results mixing vehicle flags with more general prim state flags - worth a shot though  2) llRezAtRoot http://www.lslwiki.net/lslwiki/wakka.php?wakka=llRezAtRootHope that helps some.
|
|
Seven Shikami
Registered User
Join date: 22 Sep 2006
Posts: 82
|
04-25-2007 19:13
That solves the rezzing problem! It now rezzes at the right spot. It does not, however, solve the banking problem. Here's my code, and a before and after shot of the sled about to run and how things end up going horribly wrong. vector spawn; rotation rotten;
reposition() // re-record new position. Has to be done at rez and when touched so we can move it around. { spawn = llGetPos(); rotten = llGetRot(); }
default { state_entry() { llSetSitText("Slide!"); llSetText("Slide!",<1.0,1.0,1.0>,1.0); llSitTarget(<0.0,0.0,0.1>, ZERO_ROTATION); reposition(); } touch_start(integer q) { reposition(); llWhisper(0,"Have a seat on me to slide!"); }
changed(integer change) { if (change & CHANGED_LINK) { if (llAvatarOnSitTarget() != NULL_KEY) { llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION); } else { integer perm=llGetPermissions(); if (perm & PERMISSION_TRIGGER_ANIMATION) { llStopAnimation("Slide Pose"); llDie(); } } } } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { llSetAlpha(0.0,ALL_SIDES); llStopAnimation("sit"); llStartAnimation("Slide Pose"); llSay(707,(string)spawn.x+","+(string)spawn.y+","+(string)spawn.z+","+ (string)rotten.x+","+(string)rotten.y+","+(string)rotten.z+","+(string)rotten.s); llSleep(2.0); llSetStatus(STATUS_ROTATE_X, FALSE); llSetStatus(STATUS_PHYSICS,TRUE); llSetStatus(STATUS_DIE_AT_EDGE,TRUE); llSetVehicleType(VEHICLE_TYPE_CAR); llSetVehicleFloatParam(VEHICLE_BANKING_MIX,0.0); llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY,0.0); llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.0); llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.0); llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <15, 0, 0>); } } } Images: http://pics.livejournal.com/twoflower/pic/000g2cz4http://pics.livejournal.com/twoflower/pic/000g35hk
|
|
Seven Shikami
Registered User
Join date: 22 Sep 2006
Posts: 82
|
04-25-2007 20:40
As a followup -- I tried a pose where you lie flat on your back while going down the slide. It works but you're rotated at a funny angle the whole way down, due to the friction and physics.
It's looking like this just may not work. But how the heck do other waterslides in SL work, then..? I've tried the llSetPos() script chain trick and the results are terrible, definitely not as smooth as others. What am I not getting here?
|
|
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
|
04-26-2007 13:39
it sounds like you may want to look into a train style vehicle script (only using one car) that follows a track (your waterslide) My attempts at such a script haven't been sucessful, but I've seen a few trains that have smooth realistic movement.
_____________________
My SLExchange shopTypos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not. The function is working perfectly fine. It's just not working the way you wanted it to work.
|
|
Seven Shikami
Registered User
Join date: 22 Sep 2006
Posts: 82
|
04-26-2007 13:49
That WOULD be perfect! I've seen a lot of trains in SL, even ones that can climb hills, etc, but I have no earthly idea how to make one. What's the trick? Can someone impart some knowledge..? I'd about given up on this project.
A 'train' script would be a terrific general purpose tool for my projects... tour boats going around the island... waterslides... roller coasters... even if it's just single car it'd still be terrific. Anyone..?
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
04-26-2007 15:24
The tour boats I scripted at Opportunity use a tour route in a notecard which it then follows, using vehicle physics motion. http://slurl.com/secondlife/Opportunity/116/171/21/?title=OpportunityCheck it out if you like: the rides are free. Another common approach is without vehicle physics, but incremental set positioning. The notecard approach is pretty common, but I've also played around with following scripted landmarks.
|
|
Stavros Augustus
Registered User
Join date: 14 Nov 2005
Posts: 38
|
04-26-2007 16:09
From: Seven Shikami As a followup -- I tried a pose where you lie flat on your back while going down the slide. It works but you're rotated at a funny angle the whole way down, due to the friction and physics.
It's looking like this just may not work. But how the heck do other waterslides in SL work, then..? I've tried the llSetPos() script chain trick and the results are terrible, definitely not as smooth as others. What am I not getting here? I would just put a roof over top of the slide and set its alpha to 0.
|