x


Removing velocity relative to the contact normal

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?

Cheers

more ▼

asked Jun 15, 2010 at 04:41 AM

Josh 5 gravatar image

Josh 5
11 9 6 7

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jun 16, 2010 at 01:28 AM

Josh 5 gravatar image

Josh 5
11 9 6 7

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4109
x3082
x2202
x1135
x554

asked: Jun 15, 2010 at 04:41 AM

Seen: 2298 times

Last Updated: Jun 15, 2010 at 04:41 AM