1
\$\begingroup\$

I'm working on an animation system for an RTS game. Each unit has several animation states: Move, Idle, Engaging, etc.. Units also have a variety of "Animation Impulses" which are animations that get played on top of the animation state. They're for things like shooting or casting a spell. When the impulse finishes, the unit returns to its current animation state.

Using Unity Mecanim Animators, how can I make a system like this? Is there a way to PlayOneShot an impulse animation that reverts back to a base animation when the impulse finishes?

I.e. a unit is in the state of pointing his gun at the target. The unit fires its gun and acts out the recoil. After the recoil animation finishes, the unit returns to pointing its gun at the target.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

You can use Mecanim "Triggers" to start the Shoot animation state. The trigger will reset itself to false in the next frame, so the shoot animation will play only once. Then from shoot animation make transition back to idle pointing gun state and the condition should be exit time.

Example :-

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Thanks. Is it possible to force the reset and make these triggers dynamic? So that when a unit moves in the middle of the Shoot animation, the unit stops shooting instantly and snaps to the Move animation. \$\endgroup\$
    – JPtheK9
    Aug 23, 2015 at 16:58
1
\$\begingroup\$

Reverted to UnityEngine.Animation. Works like a charm and has no performance hits.

\$\endgroup\$

You must log in to answer this question.

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