Hello, I am writing to talk about a problem I have regarding animations within my 2.5D Fighting game.
What is the problem?
So I have this system that goes as follows:
Player lands a successful hit → Sends Remote Event to Server containing Metadata (AnimationID for stun animation being the important one here) → Server Confirms it and sends a Client remote event signal to the player being hit with the animation ID → Player being hit plays the stun animation sent by the original attacking player.
The problem with this system is that, the original attacking player does not have instant feedback due to the auto-replication delay.
Any visuals?
Notice how on the left, the attacked player’s animation is SIGNIFICANTLY DELAYED whilst on the right, the same player’s animation is instant.
Shared.SyncClientAnim.OnClientEvent:Connect(function(ID: string)
local TempAnims = Instance.new('Animation')
TempAnims.AnimationId = ID
local Track = Animator:LoadAnimation(TempAnims)
Track:Play()
end)
Not sure if this is gonna help, but I’d suggest preloading all animations on the character to avoid having to create a new animation and load it every time you’re hit. Seems a bit unnecessary to me. There’s also a limit to how many animations can be loaded onto a humanoid, so hopefully you’re deleting them after they’re used.
How would I preload the animations if I’m dynamically playing new animations?
What I mean is that I’m sending custom specific animation id’s for a reason, it’s so that I don’t have a huge folder of animations to look through
I can’t really imagine you have so many animations that it becomes impossible to organize. That’s why folders exist.
Anyways, to preload animations, go through all the animations you have and load them onto your humanoid when your character spawns. Then instead of firing the animation assetid from the server, you simply give the name of the animation you want to play, then the client finds that animation you loaded earlier and plays it.
Edit: you wouldn’t even need to organize them with folders if you really want to avoid that. Can just store all the assetids in a modulescript.
Here’s a really simple example:
local AllAnimations = {};
for i,v in AnimationsFolder:GetChildren() do
local NewAnimation = Humanoid:LoadAnimation(v);
AllAnimations[v.Name] = NewAnimation;
end
AllAnimations["My Animation"]:Play()