Root Motion animations in networked games

Started by
6 comments, last by itay9 4 years ago

Hello guys!

Does anyone have experience with root motion animations, and have integrated them into a networked game? If so how did you achieve it?

Advertisement

When I did that in the past, we had to load the animation assets on the server, and roll the animation forward in the appropriate time. This in turn means that the decision engine that determines which animation to play, also has to run on the server. It worked, but it was heavyweight, in computation even more than assets (there aren't THAT many animation assets.) You'll typically want to optimize so you only derive root motion in the animation, and don't waste time posing heads and arms that don't affect movement.

If I were to do it again, I would instead make movement be physical only, and then drive the animation progress by how far the entity has moved – this is the reverse from driving movement from animation! The code you end up doing is doing this on the client:

  1. determine animations to choose between stand/walk/job/run/sprint animations based on speed of physical movement
  2. roll each animation forward in time based on physical speed divided by animation speed for that animation.
  3. blend the animations – they should be “in phase” because you roll them forward the same proportion
  4. IK fix-up of feet

Your animations will then typically be done with a full cycle in “unit time” and a parameter for how much they move. Typically, there will be a tool that removes the root motion from the animation, and instead outputs the mapping from velocity/phase to frame. If you're fancy, you can use a lookup table here, to allow for irregular speed animations.

Another physical/simulation state that might be useful to know is whether you're “running with traction” or “sliding/slipping” – it's OK to detect that feet are losing traction, and start sliding; this may even affect how input commands affect movement.

enum Bool { True, False, FileNotFound };

@hplus0603

Interesting, in my case I do run the server in the game engine which enables gives me the freedom to “play” with the animations.

hplus0603 said:
If I were to do it again, I would instead make movement be physical only, and then drive the animation progress by how far the entity has moved – this is the reverse from driving movement from animation! The code you end up doing is doing this on the client: determine animations to choose between stand/walk/job/run/sprint animations based on speed of physical movement roll each animation forward in time based on physical speed divided by animation speed for that animation. blend the animations – they should be “in phase” because you roll them forward the same proportion IK fix-up of feet

In this context, does roll forward mean, the change in object's position?

I've considered throttling the movement input that root motion animations can perform, could this be a reliable lightweight alternative to the solution you've proposed?

does roll forward mean, the change in object's position?

It means “wind the animation forward as many frames as needed to match the physically simulated movement.” If you know that the “run” animation goes between frame 0 and frame 99, and moves 4 meters in that span, and the physical simulation said you moved 0.31 meters, then you wind the animation forward (0.31/4*(99+1)) == 7.75 frames.

enum Bool { True, False, FileNotFound };

@hplus0603

Sorry for the late response I did not receive an email notification about your comment, I understand your suggestion now regarding the animation flow, it seems like an effective idea of how to implement the root motion.

If I were to apply the above logic on a game such as Dragon's Dogma - Dragon's Dogma All Warrior Skills, would the flow be as follows?:

  1. Client: Player casts a skill (Initial cast)
    1. Client: Play root animation of skill cast
    2. Client: Send skill cast packet to server
    3. Server: Receive packet, notify other clients
    4. Server Ticks: Consider the delta between the skill cast to to current tick and apply the delta movement of physical position to the next agent state (position, rotation) excluding in place movements of head/feet/body
  2. Server: Animation Event (such as "a point where the damage is applied + a visual effect of lifting contacted enemies)
    1. Server: Event triggered
    2. Server: Notify Clients to play root animation “lift” + damage deal to hit characters
    3. Server: Using the same methodology to calculate the position of hit characters based on the delta movement between frames

On a side note: do AAA companies perform a similar workflow to your suggestion?

Thanks again,

Itay

I don't know that game, but I know that some AAA companies use root motion and load the animation on the server, and others use simulated physics motion and drive the animation based on the simulation. And others just play an animation and move the character by sweeping a capsule through the world, and end up with footsteps that slide…

Which method works best for you depends on both your particular game genre, and your specific game asset pipeline and artists skills. Either way can work fine.

enum Bool { True, False, FileNotFound };

hplus0603 said:

I don't know that game, but I know that some AAA companies use root motion and load the animation on the server, and others use simulated physics motion and drive the animation based on the simulation. And others just play an animation and move the character by sweeping a capsule through the world, and end up with footsteps that slide…

Which method works best for you depends on both your particular game genre, and your specific game asset pipeline and artists skills. Either way can work fine.

Thanks for the knowledge, it gave me some options to try ?

This topic is closed to new replies.

Advertisement