Unity Animation Plays In Preview But Not When Playing Game

Blaperile picture Blaperile · Dec 5, 2015 · Viewed 18.2k times · Source

I made a simple animation for a sword gameobject to constantly slowly move up and down while the player character is standing still.

My sword has an Animator component attached:

see here

The Animator Controller is also very simple, with this animation being attached to my default state:

see here

The animation plays just fine in the preview mode of the Animation window. But when I run my game, the animation does not play at all, the sword just stands still instead of moving.

What is the cause of this problem?

Answer

Blaperile picture Blaperile · Dec 8, 2015

I finally solved the problem. It turns out that all I needed to do was turn off "Apply Root Motion" on my Animator for it to work properly.