Get tangent, hitnormal and hit angle

This is what I need
![1]

I use raycast to detect hit and then I have hitnormal and I need angle between shell and hitnormal
this is my code

    private void ProcessCollision(GameObject hitObject, Vector3 hitNormal, Vector3 hitPoint)
    {
        float hitAngle = (float)Mathf.RoundToInt(Mathf.Abs(90.0f - Vector3.Angle(hitNormal, this.velocity)));
    }

when shell hits something at 90 angle hitAngle is 90° but its supposed to be 0° because angle from hitnormal to shell is 0°

btw if keeps printing me 89,90935° than 90° so I fix float error

There are several things unclear in your setup. First of all the hit normal is usually normal to the surface you hit. So it would point in the opposite direction you have drawn it. So it’s not clear where you get that hit normal from. Did you actually visualize the normal (Debug.DrawLine / DrawRay)? Vector3.Angle does calculate the correct positive angle between two direction vectors and if the two vectors point in the same direction you get a value of 0°. If they point in the opposite direction you get 180°.

Nex thing is what’s the point of the tangent? You know that given a single normal vector there are infinite tangents to that normal. You’ve drawn your tangent horizontally which is one specific tangent which could be calculated with the cross product. Though I’m not sure what role that tangent has in calculating the hit angle?

Finally you use “this.velocity” as a direction in your calculation. We don’t know what is changing this velocity variable and if this is somehow related to a collision, be aware that when the collision happens the direction of the velocity of a rigidbody may have already changed due to the collision.

In short it’s not clear where all those values come from and if they are what you think they are. I guess the white line is the velocity direction? I’m still confused about the role of the tangent. I think you have cut down / abstracted the problem too much. At least it’s really difficult to figure out what you actually want to do here. Vector3.Angle does calculate the angle between two vectors and it always works correctly as it’s just basic maths as described here.