Hello. As the title suggests whilst I play an animation (in this case a running animation) my character teleports precisely -340282346638528859811704183484516925440 studs in the Y axis, I’m not even exaggerating. But why?
There are no bugs at all in the code, all I’m doing is juggling between 3 animations using adjust weight, but only for the part there I adjust both the speed and weight of the running animation does my character teleport to a stupid range!
ForwardWalkAnimation:AdjustSpeed(ForwardAnimationWeight >= 0 and 1 or -1)
ForwardWalkAnimation:AdjustWeight(math.min(1, MovementVelocity.Magnitude/6) * math.abs(ForwardAnimationWeight), .1)
RightWalkAnimation:AdjustWeight(math.min(1, MovementVelocity.Magnitude/6) * RightAnimationWeight, .1)
LeftWalkAnimation:AdjustWeight(math.min(1, MovementVelocity.Magnitude/6) * LeftAnimationWeight, .1)
-- Beneath this line is the issue causing this weird glitch
RunAnimation:AdjustSpeed(MovementVelocity.Magnitude/5.5/1.99)
RunAnimation:AdjustWeight(math.max(0, (MovementVelocity.Magnitude/6 - 2)/2+.5),.1)
So is this the animation itself that’s causing it? I have no idea, so what do you think the problem is?
After some more debugging I’ve found the issue looks to be the fact that Roblox has issues when playing multiple animations with different weights for each and every one of them.
Turns out that it was just that, a Roblox bug. In case anyone sees this I want to make one thing clear Optimise your code to edit no more than 4 animations at once nor play to many animations at once!!! Since Roblox hasn’t patched this yet I can only give that recommendation. Thank you @treebee63 for your tip and have a nice day
I am skeptical of this because roblox got it working.
I recommend you take a look at roblox’s strafing system as the implementation. They implemented exactly what you are trying to do with your code.
Create new place
game.Player.UseStrafingAnimations = true
game.StarterPlayer.LoadCharacterAppearance = false (strafing animation can work on your avatar as long as you’re using the default animations, otherwise it won’t work)
Hit play and spawn your character
Look in your character’s Animate
I’ve included the relevant chunk of code here:
for n,v in pairs(locomotionMap) do
-- if not loco
if h[n] > 0.0 then
if not v.track.IsPlaying then
v.track:Play(runBlendtime)
v.track.TimePosition = groupTimePosition
end
local weight = math.max(smallButNotZero, h[n] / sum2) -- non-zero weight
v.track:AdjustWeight(weight, runBlendtime)
v.track:AdjustSpeed(animSpeed)
else
v.track:Stop(runBlendtime)
end
end
You can see they used a non-zero weight here too and they’re managing over 20+ animations! Weight, FadeTime, Speed, it still works fine. I recommend you go back and compare your code to theirs, or just use their code.