Hi, we are developing a turn based game where the characters only move forward and backwards. Our investors recently suggested that we use root motion so the characters won't "slide" like they are on ice. We have never done that, so we are trying but the documentation on that is somewhat scarce and we can't get it done. We added movement to the character animation instead of leaving it in place, then in Unity we added the SkeletonRootMotion component, selected the root bone, and then we previously moved the characters with tweens from point A to point B in a given time, but is that even compatible with the root motion? Or should we be moving the character only with the animation movement and check the character position over time? If that's the case, how can we have different animation speeds depending on the distance and the time, if possible?

Thanks a lot!

  • Harald ha risposto a questo messaggio
    Related Discussions
    ...

    newxalbertus Or should we be moving the character only with the animation movement and check the character position over time?

    Yes, the concept of root motion is to let an animation dictate movement of the character, moving it's main GameObject including any physics components.

    You would either modify the playback speed of the animation, have different animations for fixed speeds (like e.g. walk and run) or have an interpolation between walking and running (a mix of the two animations) to get any speed in-between walk and run speeds.

    BTW: If your character slides during a walk animation, you don't necessarily have to use root motion but could instead calculate the distance per walk-cycle and adjust either the animation speed to desired movement, or adjust the movement distance to the animation. Games have been doing that for decades.

      Harald Thanks a lot for the response 🙂

      Then if we want to move a character from A to B with root motion, what's the best solution:
      -Play the 'walk' animation during a given time then stop the animation?
      -Play the 'walk' animation and check if the character is close to the destination?
      -Play the 'walk' animation and subscribe to the End event, and make sure the distance 1 'walk' animation cycle covers the distance we need?
      -Other...?

      Thanks again!

      @newxalbertus While it depends on your actual use case and requirements regarding the animation looking best vs. landing precisely at the target spot B, I would usually go with your second option:

      • Play the 'walk' animation and check if the character is close to the destination

      To ensure that the character is arriving precisely at position B and not the threshold epsilon-distance off, you could interpolate the GameObject position to the target position when you stop the walk animation . More precisely, you could interpolate the position over e.g. 0.3 seconds as soon as the character arrived within the given epsilon-distance of the target and use the same 0.3 seconds as mixDuration from the walk animation to your idle animation.

      @newxalbertus Regarding your third proposed solution of "make sure the distance 1 'walk' animation cycle covers the distance we need": Usually you can't reasonably adjust the distance covered by a single animation walk cycle, since this will again introduce sliding feet. However, if you move by jump instead of walking, then you can use the delta compensation feature of the SkeletonRootMotion component as described at the end if this section. This will stretch the root motion to land exactly at the target spot if your jump animation already contains motion of the selected root bone.