Hi, i have a 3D platformer game and i have some platforms where the player hits the edge and they fall off. i have setup a Trigger to detect this and works fine, however, i need the player to perform an animation depending upon which angle they jumped into the trigger. They can only jump in from 3 angles. So i have my 3 animations (work fine), i need to detect these 3 angles upon landing. Ive attached an example of I’m not making sense.
I have know idea on how to achieve this? or any advice would be great.
Detecting angles is accomplished using good old-fashioned arithmetic. Consider this approach:
Store your object’s current position at the end of each frame in a variable called lastPosition. Compare the lastPosition to your current position when you land to get the velocity-at-land-time. This will be one component of your angle check. The other component is probably some kind of constant like “Vector3.up”. Then Mathf.Angle(velocity, Vector3.up) will give you data about the “angle of the landing” you want.