Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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.