Scaling animation that takes rotation into account
Hi Everybody!
So I am making a game where a ball (the player) bounces around a small planet (think King Kai's planet). I am trying to get the ball to do a simple squash & stretch animation every time it collides with the planet or another ball.
Currently I am using the Unity Animator to affect the scale of the ball when triggered by the collision. The issue I have is that the animation is based off of the local rotation of the ball and not the ball's relative orientation to the planet. Because the ball rotates almost constantly the squash animation happens in the direction of the ball's local y axis and not the upward direction of the ball relative to the planet.
The animation is simple enough to do through code (without the Unity Animator), however, I do not know how to orientate the animation so that it is inline with the upward direction of the planet and the ball. Getting the upward direction is easy enough, but how do I scale the ball relative to this direction?
Here is a link to a short clip of the issue: https://youtu.be/mVpgaMh1rPI
P.S. I know the actual animation is a tad aggressive, it's intentional, helps me spot the issues.
P.P.S. I know the UI is bouncing around too. I'll get around to fixing that later. (any tips here are welcome too) :)
Your answer
Follow this Question
Related Questions
How to detect if a GameObject is currently rotating? 1 Answer
Rotate GameObject on specific axis 1 Answer
Can't rotate or scale object 2 Answers
Object point of rotation unknown 1 Answer