Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Racetrack start/end/lap marker strip

Mylea Latynina
Registered User
Join date: 11 Dec 2006
Posts: 1
03-31-2007 09:31
I'm currently working on a racetrack system. Amongst other things, the racers run across a strip to start, every lap, and finally to finish (same strip, looped track).

Plan A) First I created the strip, 2m long, .5m wide, and 0.01 in height, set it on the ground, and scripted it to respond to collisions... the problem i had was whn it registered a collision of the racr passing over it, if they dawdled for any reason (or sometimes not), i got multiple sets of collision_start, collision_end, and collisions in between... wouldn't be a problem but i only need the single collision, because thats got to sent a Comminication to the timer.

Plan B) I put a 100% alpha'd block ontop of the strip, set llVolumeDetect in the strip, and linked them so the strip was root. This was good... only ever one start and end.... but, no indication of direction.

Plan C) I replace the single alpha'd block with 2.... two blocks next to each other, so if the runner is running the right way, he'd hit first block, then 2nd... if running the wrong way they'd get 2nd block hit first then first..... except i'm suddely getting the 2 collide starts first, followed by the 2 collision_end events - so start/start/end/end... rather than start/end/start/end... and for that matter,there seems no way to pin down an llVolumeDetect as to which of the child prims each collision comes from....

If anyone understands what i'm trying to do, can you point me in the right direction?

Yours,

Mylea
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
03-31-2007 11:06
From: Mylea Latynina
Plan B) I put a 100% alpha'd block ontop of the strip, set llVolumeDetect in the strip, and linked them so the strip was root. This was good... only ever one start and end.... but, no indication of direction.
Take the dot product of llDetectedVel() and a vector which points in the correct direction of the track. If the result is negative, they're going the wrong way.

CODE

collision_start( integer Num )
{
if( llDetectedVel( 0 ) * < 1., 0., 0. > > 0. ) // <1,0,0> == Due East
{
// this racer is going in the correct direction
}
}


You'll want to add a loop for the rare occasion 2 racers cross the line at exactly the same time, but this is the basic gist of it.