Syncing animations/ping compensation with fadetime

Sorry if this is a dumb question/obvious answer, I’ve been up quite awhile without sleep and my brain is hating me

I’m developing a combat system, and attack animations are broken into two main phases. Windup, and release. Release plays immediately after windup, but release isn’t the problem here

When I was building this system a few months ago, there was only one idle animation for the weapon type. And thus, windups were created like this:

  • First keyframe is set to the idle animation’s first keyframe
  • Last keyframe is set to the windup pose

And when your client played the windup animation, it’d play it locally, and then send a message to the other clients, with a synchronized timestamp.

The other clients would then play the windup animation, but in order to help make sure everyone’s windup ends at the same time, I’d do

local latency = TimeModule.GetTime()-timestamp_of_attacker;
local newspeed = math.clamp(speed*(winduptrack.Length/(winduptrack.Length-latency)),speed,10);
winduptrack:AdjustSpeed(newspeed); 

The problem

I believe this worked rather well for my purposes, but the problem is now, with this new system,
since there are multiple idle animations for one weapon type that you can use, instead of having the windup track’s first keyframe be the idle animation’s keyframe, and the last being the windup pose, I’m wanting the first keyframe to just simply be the windup pose and use AnimationTrack.FadeTime to control how long it takes to reach that pose. It’d be much easier than having to create a windup specific to every idle animation type.

Is it possible to still sync up the animations using fade time? I’d think I’d just deduct the fadetime from latency in a similar fashion as speeding up the animation from latency as I did before, but the problem is I have no clue how to go about doing this, specifically how to tell when the pose has been reached. If I try printing KeyframeReached on the first keyframe, it’ll play immediately, rather than when the pose was actually reached(it doesn’t account for fadetime it seems)

Any help would be appreciated!

3 Likes