Download

Synchronize animations between actors

While making a horse actor I realised that I don’t know how to play it’s animations synchronously with the rider. That ones with PlayCustomAnim are simple to make, but what about walking and running animations? Rider is attached with SetBase and technically does not moves. Animations could be toggled with a custom animnode, but how to be sure they are synchronized with horse’s animations shown on this screenshot?

793f5ca4b7fb4fe0d3512a61271155c07438eb13.png

I was using notifies in the horse animations to play animations on the player. I’m using two animnodes to mix the animations, so there are no hitches.

But it seems a “brute forze” way to do, I want to try with the syncronize groups, but still I don’t know if they will work with two diferent actors and two diferent animtrees.

The problem is ScaleRateBySpeed nodes that continuously change animation rate, so even if I start playing rider’s animation at the same time, I cannot tell which rate it must have at every tick.

I made a setup that detects a change of horse’s animation and replicates it to rider pawn. A custom anim node that passes OnBecomeRelevant() to pawn class did the trick.

Then I tried to get the play rate of anim node sequence with GetGlobalPlayRate(). The description said it will take into account all rate scales applied to this animation, but as appears, it ignores ScaleRateBySpeed node and simply returns 1.0.
Well… is there a simple way to get play rate of animation after it’s being modified by ScaleRateBySpeed node?

In my new horse I used the notifies and no mixing for animations. I tried to use animation groups with the same name in the animtree of the horse and rider, but seems that the sync only works in the same actor.

I have used a notify in the horse anim, at the start of animation. This notify calls a horse function that does this:

Use worldimeseconds to the function can’t be called twice. Probably because the anims groups calls each one when mixed. Using timeseconds are called one for each anim cycle.

I took the horse velocity and divide it by a number, a factor. In this way I have a the rate for the rider anim. I had to test a lot of numbers until find the correct values for each horse animation.

Play the animation in the rider, using these rate value, and the override bool set to true. If the rate is accurate, the animation just begins when the last cycle are finished. As the horse velocity can vary each tick, in this way you update the rate for the rider in each animation cycle.

The result is no perfect, anims are late sometimes when the horse change the run anims, but the sync are good the most of times.