# Following a 3d track

This topic is 2836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi Guys,

I'm creating an app whereby the vehicle goes around a 3d track (represented as triangles). The track can rotate through all directions (like a roller coaster) and I was wondering how to implment the physics of the vehicle (this is not a question about the maths, just the general idea).

I was thinking that at each update I would find the closest triangle on the track to the vehicle's new position, get the normal for that triangle and then position the vehicle at the point within the triangle at a certain distance above it.

Is this a good method to acheive what I want or is there a better one?

So the steps would be:

1. Query Octtree to get all triangles around the vehicles new position.
2. Find the closest point to the vehicle on one of these triangles
3. Set the vehicles position to say 5 units above this point (using the normal of the closest triangle).

How does this sound?

Any comments would be really appreciated,

Cheers,

Chris

##### Share on other sites
I think the method you describe is fairly standard (although it might be a little more common to cast a ray directly downward from the object to find the intersection point and normal).

If you also want to align your object to the surface, this can be done by applying a corrective rotation each update that rotates the object's up vector onto the normal of the surface beneath it.

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 30
• 41
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631741
• Total Posts
3001980
×