I'm looking to find out what the velocity of a rigidbody is on a specified local axis.
I'm building a simulation/shooter based on scifi airship warfare, which includes both planes and floating anti-gravity airships. For the planes, I'd like to get the speed along the z-axis for a simplified calculation of lift. In aerial geek-talk, I'm basically interested in Indicated Airspeed.
For the airships, it will be used to aid calculating collision damage, hopefully in conjunction with a normal-line between the colliding parts. The logic is that fast-front hitting damage will do more than a gentle glancing bump.
Can anyone suggest the most efficient way to do this? I'm really looking for the closest actual equivalent to "rigidbody.GetLocalVelocity(z);"
I'm confused. Why can't you just use `Rigidbody.velocity.x/y/z` , or `GetLocalVelocity()`, as you said?
You could also write your own speed calculator, just save the x/y/z position from the previous Update and then subtract it from the current one, which gives you the speed. Something along the lines of:
float lastPos;
float speed;
void FixedUpdate()
{
speed = Mathf.Abs(lastPos - transform.position.z);
// or position.x/y if you need that
lastPos = transform.position.z; // or x/y.
}