Game Development Community

Finding nearest point on a surface

by Shawn Simas · in Torque Game Engine · 09/23/2006 (9:20 am) · 3 replies

I'm modifying wheeled vehicles to have no true gravity, and stick to whatever surface they are on.

So far I check if the wheels are touching, if they are, I use the normals from the wheels to get the direction of gravity. If no wheels are touching I shoot a ray down from the vehicle and see if it hits a surface (interior/terrain), if it does, I use the normal of the ray to push down.

Now, my problem is if that ray doesn't hit, and there is nothing directly below him, I am going to want to push against the nearest surface. How do I find it?

I think casting a series of rays along different axis, and then finding the nearest wouldn't be the best way, because it would be quite a performance hit... especially if you have quite a few players in a game...

any suggestions would be greatly appreciated :)

#1
09/23/2006 (9:24 am)
Have you taken a look at Player::findContact ()?
#2
09/23/2006 (9:26 am)
I don't think ray casting is actually a heavy task. I have particle emitters that fire out 50-100 particles, all of which have raycasting applied to allow them to bounce off things, and I don't notice any problems.
#3
09/23/2006 (9:41 am)
Stefan: I haven't, looks kind of scary though... I'll read through that.

Sam: Hmm. In that case I guess I could cast out a few rays a player... since it would only be when the other cases are not happening either...

I guess I'll look into these two options :)
Thanks