So I have a dash function and a corresponding animation:
The dash animation shown slightly raises the root part in the middle of its sequence as such:
This doesn’t affect the motion of the dash whatsoever at first. However, after respawning, the dash (and any other function that operates the same, with raised animation) becomes distorted as such:
The dash uses a module script which is fired on input, here is the relevant code for the dash:
local function EaseOutQuad(t)
return 1 - (1 - t) * (1 - t)
end
local attachment = Instance.new("Attachment")
attachment.Name = "DashAttachment"
attachment.Parent = root
local dashVelocity = Instance.new("LinearVelocity")
dashVelocity.Name = "DashVelocity"
dashVelocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
dashVelocity.MaxAxesForce = Vector3.new(100000, 0, 100000)
dashVelocity.Attachment0 = attachment
dashVelocity.Parent = root
while tick() - dashStart < dashTime do
local cameraVector
if direction == "Right" then
cameraVector = camera.CFrame.RightVector
elseif direction == "Left" then
cameraVector = -camera.CFrame.RightVector
end
local elapsedTime = tick() - dashStart
local progress = elapsedTime / dashTime
local easedProgress = EaseOutQuad(progress)
local currentSpeed = initialDashSpeed * (1 - easedProgress)
if currentSpeed < minDashSpeed then
currentSpeed = minDashSpeed
end
local dashDirection = Vector3.new(cameraVector.X, 0, cameraVector.Z) * currentSpeed
dashVelocity.VectorVelocity = Vector3.new(dashDirection.X, 0, dashDirection.Z)
task.wait()
end
I’ve isolated the cause by removing the movement of the root part from the animation, which allowed the dash to work as it should every time but without the upwards motion it didn’t look nearly as good.
What I tried then is to just add the upwards movement manually via the code, however I’d want to avoid this as it also raises the camera as such:
So yeah, I’m pretty stumped as to why exactly this occurs and how to fix it. I’m using a module for loading in animations, but manually loading them onto the animator ends up with the same problem.