One might use a coroutine to interpolate an object's position from point A to point B.

What I'm trying to do is store that interpolation as a Unity Animation file, but have the ability to manually enter points A and B each time it plays.


I have a simple Animation — a "jump", if you will — which I want to chain with the aforementioned interpolation:

  • the object does a little jump;
  • mid-air, the object moves/interpolates to another position.

Of course, I could do this by playing the coroutine after the first animation is done, but it'd be cleaner to store both as Animation files and use an Animator Controller to manage them, especially since the 2 animations are technically parts of one whole.

Is that possible?

If so, how could I record/create it? If not, what's a clean alternative?


2 Answers 2


It sounds like what you want is Animation Parameters.

Animation Parameters are variables that are defined within an Animator Controller that can be accessed and assigned values from scripts. This is how a script can control or affect the flow of the state machine. [...] For example, a script can set a parameter to control a Blend Tree.

Parameters can also be used to control animation speed, etc.

  • 4
    \$\begingroup\$ This answer would be better if it demonstrated how to use animation parameters to bring the object to a specific target position as described in the question. \$\endgroup\$
    – DMGregory
    Commented Aug 19, 2020 at 16:46
  • \$\begingroup\$ Sorry for the late reply (was working on other features) but how would that work? You can't define a Vector2 parameter, so how else would you specify what position to animate to? \$\endgroup\$ Commented Aug 21, 2020 at 9:18
  • \$\begingroup\$ @verified_tinker Good point, didn't fully think this through. In that case I'd say you're best off using a coroutine. \$\endgroup\$
    – Kevin
    Commented Aug 21, 2020 at 16:33

Animations in Unity are made to be predefined and pre-setup, so you cant modify them (at least not that I know of). You are probably best of using no animations and just using Coroutines, at least I think that would be easier. That way you can call another Coroutine after one has finished. Similar to how you would do it at the end of an animation. It would probably be a much "cleaner" method. As it would be all-code rather than a mix of animation and code.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .