- Home /
Question by
shark83 · Nov 29, 2018 at 05:09 AM ·
velocityanglenormalvector3.angle
Vector3.Angle outputs different results for the same values
I've been using Vector3.Angle to determine the angle at which a ball hits a wall.
private void OnCollisionEnter(Collision collision)
{
Vector3 normal = collision.contacts[0].normal;
Vector3 velocity = GetComponent<Rigidbody>().velocity;
Debug.Log("Normal: " + normal + "Velocity: " + velocity + "Angle:" +
Vector3.Angle(velocity, -normal));
}
Even though 'Normal' always remains at (0.0, 0.0, -1.0) and 'Velocity' at (0.0, 0.0, 0.0) when the ball hits the wall along its normal the 'Angle' will sporadically output 180 or 90 sometimes. Any idea why or how to fix?
Comment
Your answer
Follow this Question
Related Questions
Angle and Velocity in a Projectile 1 Answer
Is it possible to have a shader that draws various textures based on normal angle? 1 Answer
Angle between Ray and Normal 1 Answer
Projectile not firing right - simple angle and velocity problem? 2 Answers
Collisions, Getting the Normal of the Collision Surface (Not the Angle of Impact) 1 Answer