Having an issue with a fast moving object going through the track; at the moment the track is detected using Raycasts and uses this information to position itself ontop of the track and oriented correctly (wipeout style game).
It's a classically case of object move increments being greater than the area being checked - I have moved the colliders higher which has helped a little. The problem is specific to hitting corners or tilted track segments.
The 2 solutions I have are:
1) Shoot rays from the bottom; if nothing is detected then shoot rays in the opposite direction (having performance issues at the moment so not wanting to go down this route).
2) Remove the velocity relative to the contact normal (or transfer that velocity to the facing direction or perpendicular to the track) - this is the approach I would like to take but not 100% sure how I can remove the this velocity. I have multiplied the -velocity by the normal and added this current velocity but this is (obvious that know what they're doing) not the right approach.
I noticed that the CharacterController's Move method is capable of 'sliding' the object along a collider - anyone know how the team at Unity would have implemented this?
asked Jun 15 '10 at 04:41 AM
This appears to have worked for me...
velocity -= Vector3.Project( velocity, trackContactNormal );
Where velocity is the (obviously) objects current velocity (done manually because I needed something similar to the CharacterController but specific to a vehicle of sorts) and trackContactNormal is the contact normal from the RaycastHit object.
Has stopped me falling through the track when moving at pace; it is possible to transfer this velocity to the forward direction but I have decided not too to save some processing time.
answered Jun 16 '10 at 01:28 AM