MeshesIntersect

Blitz3D Forums/Blitz3D Beginners Area/MeshesIntersect

Pete Carter(Posted 2008) [#1]
should i use MeshesIntersect to see which car crosses the finish line/check point in my racing game or is there a better way? im using jv-ode but i dont think you can have collisions just for triggering that alow object to pass though uneffected?


Ross C(Posted 2008) [#2]
You could parent a pivot to the front most point of each car. Have a quad over the finish line. Then check for collisions between the pivot and the quad. Since the quad is parented to the car, it won't affect the car in anyway either :o)

Should be alot quicker then meshintersect


IPete2(Posted 2008) [#3]
Pete,

Yeah meshes intersect is how I do some of the collision detection in my stuff, especially when you don't want a collision to effect how the colliding object is moving...Ross's idea is good too though!

IPete2.


Pete Carter(Posted 2008) [#4]
ok cool ill give ut a try. I had an idea a few minutes ago, with ode I can just make a small part of the track a 2nd trimesh and when a wheel touchs it i can get the collision but im not sure i can identify the car thats driven over the line just that a car has collided with the strip? ill have to ask VIP3R

thanks for your help


Ross C(Posted 2008) [#5]
Problem with using the wheel, is the cars might be different shapes. The pivot idea is pretty fast, that's the only reason i suggested it :o) Hope you get it working.


Stevie G(Posted 2008) [#6]
No need for collisions. The easiest way is :

Position a pivot in the center of the starting line
Point it in the direction of the track
Then all you need to do is check that the car is infront of the Pivot like so ...

tformpoint 0,0,0,Carmesh, Pivot
If tformedz() > 0 and tformedz() < 20 and abs( tformedx() ) < TrackWidth
;you have crossed the finish line
Endif

Note that the 20 should be changed to suit.

Only problem is that it'll continually register a lap when you don't want it too. This is where checkpoints should be used ... say 10-20 around the track. Store the current and target checkpoints and when the above condition is met you set the current checkpoint to the target and set the target waypoint to the next one. A lap should only be registered when your current checkpoint has been registered as the starting line pivot.

Make sense?

Stevie


Ross C(Posted 2008) [#7]
But what if the cars are different lengths? Wouldn't you need to set the entity's(0,0,0) to the very front of the car. If not, and you get an instance when two cars are at the same position centrally, but the larger car has passed the finish line, so wouldn't be so accurate.


Stevie G(Posted 2008) [#8]
Voila ...

tformpoint 0,0,CarLength*.5,Carmesh, Pivot
If tformedz() > 0 and tformedz() < 20 and abs( tformedx() ) < TrackWidth
;you have crossed the finish line
Endif


Ross C(Posted 2008) [#9]
Hehe, nice :o)