Calculate collision angle [c#] Weird results?

I want to calculate the angle of a collision between A) The player character and B) the floor, a wall, or another character.

I want to calculate this so that later on I can determine how much damage different collisions will do to the player. Unfortunately the results I get seemed to be unrelated to the angle at which i’m actually colliding my object into the testing object.

This is my code, based on this Unity Answer:

	void OnCollisionEnter(Collision collision)
	{
		Vector3 normal = collision.contacts[0].normal;
		Vector3 myCollisionVelocity = rb.velocity;

		collisionAngleTest1 = Vector3.Angle(myCollisionVelocity, -normal);

		Debug.Log("AngleTest1: " + collisionAngleTest1);
    }

Here are a couple of screenshots of my floating character being test-collided into a wall.

On scene-start, if I collide the character directly into the wall without steering at all the debugger returns either 90 degrees or 0 degrees. But when coming at a shallow angle as indicated in the second screenshot I often get returned angles of 80, 75, even things like 110. It just doesn’t make sense to me. The angle that comes back in the debugger seems completely unrelated to the angle that I decide to collide with the wall.

It’s worth noting that my character objects rotates and spins when it is bashed into things. ‘W’ adds force to the character in the direction the camera is looking (but force is locked to the horizontal axis to better examine my results while trying to fix this). So there is no real up, down, left right as far as the character is concerned, it is just propelled in the direction that the camera is looking. The character has a standard sphere collider attached and rigibody.

Can anyone see where i’m going wrong? I’ve tried tweaking my code so much; even recreating this solution here which yields very similar (but wrong) results as the above method. The code for this is here:

    void OnCollisionEnter(Collision collision)
    	{
    		Vector3 orthagonalVector = collision.contacts[0].point - transform.position;
            Vector3 myCollisionVelocity = rb.velocity;
    
    		collisionAngleTest2 = Vector3.Angle(orthagonalVector, myCollisionVelocity);
    
    		Debug.Log("AngleTest2: " + collisionAngleTest2);
        }

Okay so – Moving Vector3 myCollisionVelocity = rb.velocity; out of the OnCollisionEnter function seemed to have fixed the problem. Code below:

void OnCollisionEnter(Collision collision)
{
    //COLLISION ANGLE
    Vector3 normal = collision.contacts[0].normal;
    collisionAngle = 90 - (Vector3.Angle(myVelocity, -normal));
    Debug.Log("Collision Angle:" + collisionAngle);
    //
}

So far this seems to be working nicely.