Search Unity

Question Animating a simple cube to make it 'roll' on all sides

Discussion in 'Animation' started by GamesbyJP, Mar 8, 2021.

  1. GamesbyJP


    May 20, 2018
    Hello everyone!

    I'm having trouble getting a cube to 'roll' on its sides with the animator.
    I've split the movement up in two animations, and each animation plays on its own object in a parent-child relationship.

    So I have the cube parent to handle the position change in the x z plane, which works fine.
    The animator on this object has root motion enabled.

    I also have a rotation of the cube (child of cube parent), which seems to reset no matter what I try.
    A common solution to this problem online appears to be to disable "write defaults". But this just results in the rotation applying and then slowly resetting instead of the rotation resetting immediately after it's applied.
    The animator on this object has root motion disabled, because otherwise the object would not rotate.

    The default state is an empty state with no animation, while the forward, right, left and backward states are transitioned to by setting a trigger to true.