Unity: Object World Positioning

We used scripted animations in our latest game. These scripted animations were used since our start and end point would change based on how you played the game. So instead of making 30 x 5 combination of animations, we decided to script the animations with dynamic start and end points.

For the animations, using something like ease in and out instead of linear, worked great for the timing. But the motions of the scripted animations looked too robotic. It’s hard to script a flowing animation like you can do in the animation inspector.


These are easing functions we used.

https://easings.net/


Now the problem we ran into was making the scripted animations look nice. I decided to use Unity’s animation keys as my base for the scripted animations. So I would make the nicer fancier animations using Unity’s Animation window. Then use those values to populate gameobject positions in scripted animations.

Sadly, our scripted animation system was written in Object World Space Coordinates whereas Unity’s animation window uses Local Space Coordinates. So I found this quick script to get the converted coordinates in the debug window and copy the values over to the script.


Here are the 2 blogs resources I used to find the script.

https://forum.unity.com/threads/can-i-see-global-coordinates-in-the-inspector.247453/

https://discussions.unity.com/t/how-to-get-to-the-editor-to-display-a-childs-world-position/12069/3