I’m making a custom walking animation script and am using already playing animation tracks, then adjusting the weight according to the direction.
However, when I use this code WalkLeft:AdjustWeight(10,0)… WalkLeft stands for an animation track that is already playing but has a weight of 0.
When I run this code the target weight changes but the current weight of the animation doesn’t.
Whoops, I got confused because the ChatGPT reply was deleted.
@OP
Hmmm your code seems correct. I thought weights should be between 1-0 though, so maybe change your code to WalkLeft:AdjustWeight(1,0)?
The second argument (0) is correct if you want there to be no fade time between the weights.
It’s strange that the target weight doesn’t change the current weight. I would add some code to check if the current weight is being changed over some time. It might be that the current weight changes the next frame when fade time is zero.
Edit:
I’m not sure. Your code looks correct to me. I would try doing small tests to rule out problems. (For example, you could do a test where you just change the weight of an animation outside of a loop. Then if that works do a test where you do the same thing but inside a loop, etc.)
if FrontToBackNumber > 0 then
WalkForward:AdjustWeight(FrontToBackNumber)
WalkBackward:AdjustWeight(0)
elseif FrontToBackNumber < 0 then
WalkBackward:AdjustWeight(FrontToBackNumber)
WalkForward:AdjustWeight(0)
else
WalkForward:AdjustWeight(0)
WalkBackward:AdjustWeight(0)
end
if RightToLeftNumber > 0 then
WalkRight:AdjustWeight(RightToLeftNumber)
WalkLeft:AdjustWeight(0)
elseif RightToLeftNumber < 0 then
WalkLeft:AdjustWeight(RightToLeftNumber)
WalkRight:AdjustWeight(0)
else
WalkRight:AdjustWeight(0)
WalkLeft:AdjustWeight(0)
end
This code is played every heartbeat of the local players screen using, RunService.Heartbeat:Connect()
FrontToBackNumber and RightToLeftNumber are a number between 0 and 1, yet this still doesn’t work. What am I doing wrong?
Okay, I solve it, apparently, it was the dumbest problem with Roblox itself.
So if you play an animation with a weight of “0” then you can’t adjust the weight anymore, but if you play it with a default weight value of 0.00001… or anything above 0 then you can adjust the weight just fine.
I really think this needs to be fixed since it seems so useless to have it like this.
Ah. That makes sense, that would actually help me for the future.
I think the reason why it does this is that setting it to a weight of 0 essentially does the same thing as :Stop(). I see why this happens but its annoying.