So I was working in Unity the other day on a shooting gallery style game for my final year project only to find out that they had updated the animation system in Unity 4.3. Previously it was super easy to apply basic animations (as displayed in this now obsolete video tutorial) but I found it quite tricky to figure out how to apply a basic animation with the updated system. After about 30mins of trying to tinker with the editor I threw my hands up in the air and said “I’m a programmer, let’s sort this out using a script!”. The solution did end up using a very basic script but it also taught me something that I find very cool about animations in Unity.
Here’s the script that I used to make a game object/target “pop up” in my shooting gallery:
As you can see it’s very basic; the position depends entirely on the YPosition variable. I attached this script to the game object I would like to move and then also added an Animator component with one state/animation. The animation looks like this: