I’m using :AdjustWeight in order to blend 27 animations consisting of 8 walking, 8 crouch, 8 prone, and 3 idle states. It works fine on the client and all the weights add up to close to one.
However, when I printed out the sum of all weights on the server, as I was transitioning to different directions rapidly, the sum of the weights was less than one.
When the update frequency is 0.3 seconds, the sum of weights on the server is always 1 or close to 1, as expected, but the character doesn’t feel responsive or fluid.
I want to know what I can do to fix this.
Thanks!
while true do
Update()
local sum = 0;
for i,v in pairs(animations.Movement) do
sum = sum+v.WeightCurrent;
end
for i,v in pairs(animations.Idle) do
sum = sum+v.WeightCurrent;
end
print(sum)
wait(0.3)
end
Have you tried setting the animations’ weights on each peer separately? If the AdjustWeight loop is repeated many times per second, I think it’s a good idea to make each of the weight values as a function of time.
That is: if tick() is equal to 1560059384000 (for example), the weight of walking animation No.1 will always be 0.29578403.
This is a common problem I run into also even with the 10 or so years that I’ve been scripting on Roblox. Usually the problem is either you’re updating something too quickly and it’s sending to much data, you’re updating too many things at once (which is most likely the problem you’re running into), or it’s due to ping (which is probably not it considering this is in studio).
I would actually recommend sending this over a RemoteEvent from the client in one big table and then having the server bounce this back to all other clients.
This will greatly reduce the stress from replicating all 27 animation’s states and should make sure clients remain consistent.
As @VisualPlugin also said it’s a good idea to use tick to sync animations like this so that way you don’t need to replicate anything.
Also fun fact: According to the wiki’s 50kbps limit you can theoretically send a maximum of ~853 bytes to a player per network frame (currently synced with Heartbeat) over remotes before data is queued for the next network frame.
Since 27 animations could have caused excessive network stress, I removed 18 of them to only test the 9 prone animations.
However, even with 9 animations at an update frequency of 0.15, the problem persists.
I could use remote events to replicate the animation weights, but I would prefer to rely on the built-in animation replication and to avoid making a custom replication system.
When the sum of weights is less than 1, the prone animations have a reduced influence and the character attempts to raise itself into its default standing stance.
If the animation weights are randomised, I’m saying we use the same random seed (i.e. tick()), so that the client and server will reach the same values independently of each other.