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?
Answer by Josh 5
Jun 16, 2010 at 01:28 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.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
No one has followed this question yet.
Trying to avoid collision with sides and interiors of polygons
How do I detect when two CharacterControllers collide?
How to stop CharacterController during Collider's moving?
Character controller not colliding with enabled box collider
Physics AddForce reduced when 3 objects are colliding