relativeVelocity.magnitude for some angle only

How can I write a code for checking collision.relativeVelocity.magnitude for some angle?

  • I need to check a collision while landing the aircraft.

If I fall down, plane explodes offcourse. But if I land with some forward speed and touch the ground lightly, it should be ok. This is not possible with collision.relativeVelocity.magnitude > 5 (for example 5), because it explodes too. I guess, I need to check some angle for what magnitude works only.

when y is up direction just check the y component of the normalized vector. but if it matters how fast the plane is use unnormalized vector.y so you have the pure up/down component.

Use:

Vector3.Dot(collision.relativeVelocity.normalized, rigidbody.velocity.normalized) * collision.relativeVelocity;

You could replace rigidbody.velocity with any Vector3, as long as it a normal.

thx. Anyway, I don’t know how to use this in script. :frowning:

Then you should learn more about scripting. You have two good solutions in this thread. Either one or the other will do exactly what you want.

Start by going through a lot of Unity tutorials, or tutorials on how programming languages work in general. Then eventually you will see how easy it is to incorporate the solutions given you today.

Typo error, it works like a charm, thank you.