Issue
Running Animator:StepAnimations
causes changes to be made to the Motor6D.C1
and Motor6D.CurrentAngle
properties of the joints in a rig.
The only way to reset a rig after using Animator:StepAnimations
is to manually reset Motor6D.C1
to its original value and Motor6D.CurrentAngle
to 0.
Expected Behavior
Previewing an animation using StepAnimations
changes only Motor6D.Transform
, as it does for regular animation playback.
Once an animation has finished previewing the rig should be able to be reset by setting Motor6D.Transform
to CFrame.new()
Actual Behavior
StepAnimations
does not change Motor6D.Transform
but instead changes Motor6D.CurrentAngl
e and Motor6D.C1
that need to be reset manually once the animation has completed.
Repo file
Please find attached a file demonstrating the bug. To run it, copy the code from the script in Workspace and run it in the command bar.
RESET_C1_AND_ANGLE
is set to false by default to demonstrate how the rig’s joints are not reset to their original orientation unless C1 and CurrentAngle are reset.
TransformBug.rbxl (20.6 KB)
I remember I worked around this issue when making the Animation Editor plugin use StepAnimations for previewing animations.
I believe only the CurrentAngle property is changed by StepAnimations, not the C1 property of the joint. If I recall correctly this bug is not actually caused by StepAnimations but rather it’s a bug with using AnimationTrack:Stop() with fadeTime of 0. The same bug occurs while running animations normally and calling Stop with a fadeTime of 0.
Here is some repro code that demonstrates the issue without using StepAnimations:
local ANIM_TRACK_STOP_TIME = 0
local PlayersService = game:GetService("Players")
local RunService = game:GetService("RunService")
local localPlayer = PlayersService.LocalPlayer
local character = localPlayer.Character
local humanoid = character:FindFirstChildOfClass("Humanoid")
local animateScript = character:FindFirstChild("Animate")
if animateScript then
animateScript:Destroy()
end
for _, track in pairs(humanoid:GetPlayingAnimationTracks()) do
track:Stop(0)
end
RunService.Stepped:wait()
for _, descendant in pairs(character:GetDescendants()) do
if descendant:IsA("Motor6D") then
descendant.CurrentAngle = 0
end
end
wait(1)
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=507770677"
local animTrack = humanoid:LoadAnimation(animation)
animTrack:Play()
wait(1)
animTrack:Stop(ANIM_TRACK_STOP_TIME)
I’m not sure why I wasn’t able to fix this issue instead of working around it in the Animation Editor but I think it should be possible to fix the behavior of AnimationTrack:Stop(0).
Even removing the :Stop()
line, it seems odd that the joints don’t reset when Motor6D.Transform
is reset after the animation has run. After all we aren’t firing StepAnimations
any more…
I’m not sure what you mean, the CurrentAngle property is still different than the original value because it’s being changed when you run StepAnimations. I don’t think this is a bug because the CurrentAngle property is also changed when running animations normally.
Aha - I wasn’t aware CurrentAngle was changed. Good info, thanks.
Is CurrentAngle supposed to be changed during animation playback?
I’m not 100% sure but I think this is intended, maybe someone with more knowledge of the system can clarify this.