Hello all. I was messing around with programming tank treads. I'm simply using a texture that slides across a model to simulate treads. Thing is in order to move this I need to "fake" the treads moving along the ground. To do this I decided to just check if the treads are on the ground and use "rigidbody.AddRelativeForce" to move it forward when it is. So everything is working fine except one problem.
I don't know how to check the relative velocity to set a speed limit.
Right now I am simply using "rigidbody.velocity.magnitude" to check the speed, but that only gives me the total velocity, I want the velocity relative to the direction the treads are pointing. That way if I am moving at the speed of sound sideways, you can still push yourself forward instead of having to wait for the tank to slowdown so you can move where you want to go. Another problem is if you were being pushed backwards you wouldn't be able to push back which would really suck. Anyway to make the velocity magnitude nice and rotated to only look at one axis of movement relative to the object? Specifically the Z axis?
You could just check the z component (rigidbody.velocity.z) instead of the magnitude.
answered Jul 22 '11 at 02:53 AM