Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Getting multiple root-motion characters to walk at the same speed

Discussion in 'Animation' started by falsevac, Mar 24, 2023.

  1. falsevac

    falsevac

    Joined:
    Mar 16, 2016
    Posts:
    33
    I have several player-controllable characters. Their animations are driven by root-motion. During some periods of the game, all the characters follow the character that the player is currently controlling. The characters each move at different speeds, and I want to make it so the group all walks at the speed of the slowest character in the group.

    I have tried various methods of trying to calculate the average root-motion speed of each character, finding the slowest, then applying the % difference as an animator parameter to affect the playback speed. But, none of my attempts work that well.

    Any ideas? Thanks.
     
  2. ShinAli

    ShinAli

    Joined:
    Sep 24, 2011
    Posts:
    36
    You can use the OnAnimatorMove callback to apply the root motion yourself; you can use the deltaPosition and deltaRotation properties on the Animator object to determine how to apply the movement. From what you said, you'd just apply the multiplier against deltaPosition and use that to add to your transform's position.