Unity Tips: The AnimationCurve Example

How to use the AnimationCurve class to animate GameObjects

BlueBubbleBee
4 min readJan 7, 2020

It amazes me how Unity provides tons of different tools to work. Today I bring a new quick tip that you can use for your games, the Curve Animator.

This simple tool gives you the ability to programmatically animate game objects.

It’s a dream come true for a programmer like me who likes to make programming animations by code… Not, not really, but I like it.
The idea behind this class is simple, in a simple MonoBehaviour Script, you add the Curve Animator element, and a visual curve allows you to adjust the “animation”.

The examples are countless, here some of them:

  • Animate a cube up and down with different velocities.
  • Animate an object that comes toward you from far away.
  • Animate an object pop in from the bottom

In this example, I am going to demonstrate how to create the second example, a game object that spawns far away from you and goes toward you moving in a nice direction.

Does this example ring a bell? Do you know that game that spawns objects far away from you and they come toward you, and your goal is to slice them?

--

--

BlueBubbleBee
BlueBubbleBee

Written by BlueBubbleBee

I am Bee, an indie developer making Kitori Academy a cosy life sim where you take the role of a wizard apprentice and have a cat as a companion!

Responses (1)