Search Unity

Animations/Animator break movement functionality

Discussion in '2D' started by Jinxology, Dec 5, 2013.

  1. Jinxology

    Jinxology

    Joined:
    Jul 13, 2013
    Posts:
    95
    Greetings,

    I imported the 2D Platformer demo, and tried to mimic moving the "hero" around the screen. I created an empty GameObject called wizard, added some child sprites (body, left arm, right arm), added the PlayerControl.cs file, and he moves around just great.

    Whenever I add an Animator component with an idle state and add an animation (a slow vertical bob), the wizard no longer moves when I hit the left and right keys. Disabling the Animator fixes this.

    Also, upon hitting Play, although he does indeed bob in his idle animation, the wizard snaps across the screen to a new spot. It feels like a problem with world space vs local space, but I'm attempting to copy exactly how "hero" is setup, and not seeing any differences.

    Pulling my hair out. Any help would be appreciated.
     
  2. JHHemphill

    JHHemphill

    Joined:
    Jul 24, 2013
    Posts:
    7
    Check out your Animation tab for the animation clip and make sure you don't have the GameObject's translation keyed.

    If you're doing the bobbing with the parent-most object (as opposed to a child sprite within the group), or even if you keyed it by accident by moving it, this could be the problem. We were running into the same thing, where turning off the Animator would kill animations, but it would move properly.

    Having keys on the parent group would break movement for one of our characters. My guess is was absolutely defining the translation in the animation in the world, not allowing anything to affect it, whereas the children of the group move relatively to the parent object. Also, even when there was a different animation in the AnimationController that has translation set on the parent object, it would cause translation to break.