How to find the 'longitude' of a collision location on a sphere collider?
I have a situation where a character is being punched in the head (which has a sphere collider), and I want to call an animation blend tree that deflects the head in the proper direction. So, one of the values I need for this (assuming the Y axis points upwards) is the Y-coordinate or longitude at which the collision happened. I expect most hits will be slightly off-center (the movement vector of the incoming object will never point exactly to the center of the collider). You can think of it like a meteor impacting the earth; they rarely come straight inwards, instead they usually graze sideways and strike at an angle.
So far, everything I've tried is either incompatible with eulers, or I can't grasp the math required to convert it. The collision.contacts[0].normal gives (roughly) the normal of the collision point - but I can't find any way to convert that to to Euler degrees. And that only works when the hit is along the 'equator' of the collider, as otherwise (imagining that the collision is at the 'south pole') the other coordinates will have far greater values. I hit the same problem if I do the math to get the vector between the collision location and the collider's center.
What am I missing or overlooking? I know I'm trying to get a 2D coordinate from a 3D sphere, but there must be some simple approach. In this particular case the collider isn't well aligned with the global default locations, but I should be able to figure out at least this part.
Your answer
Follow this Question
Related Questions
Annoying Quaternions and Eulers 1 Answer
Euler Angles in code / inspector different (both local & global) 1 Answer
Quaternion.Angle() unexpected output. Compare to Vector3.Angle() which produces correct values. 0 Answers
How to invert just z axis of incoming quaternion 1 Answer
Quaternions to EulerAngles weird x-axis interaction 1 Answer