Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't my animation slow down after using AdjustSpeed()?

Asked by 6 years ago

I'm working on a shooter game that requires the player to reload after they use up all their bullets in a clip. Each gun takes different length of times to reload, so I need to change the animation length to fit the reload time. I've currently tried the AdjustSpeed() method to change the speed to play at 75% of it's original speed (which, I've tested, prints out 0.75 as its speed), but when the animation track is played using :Play(), the animation does not appear to be slowing down.

Here is the function for reloading:

function reload()
    reloading = true
    reloadAnim:AdjustSpeed(reloadAnim.Length/reloadTime.Value) -- Anim speed does change, but it doesn't appear to slow down when played??
    print(reloadAnim.Speed) -- Prints out 0.75
    reloadAnim:Play() -- Animation finishes playing a noticeable amount quicker than the wait() time, despite having its speed changed to 0.75
    wait(reloadTime.Value) 
    clips.Value = clips.Value - 1 -- Clip and ammo values changes a while after the animation has finished playing
    ammo.Value = maxAmmo.Value
    reloading = false
end

reloadAnim is an already-loaded AnimationTrack that has an original length of 1.5 seconds, and the reloadTime.Value is 2. The reload function is called with reload() once when the player presses the "R" key.

If there is not enough context to solve this issue, please let me know.

0
Could you possibly post the other code. Like when they press the R key User#19524 175 — 6y
0
"reload()" is the only code that will run when the key "R" is pressed, I used UserInputService to listen for the input. khfong71 10 — 6y

1 answer

Log in to vote
0
Answered by
cactz 15
3 years ago
function reload()
    reloading = true

    print(reloadAnim.Speed) -- Prints out 0.75
    reloadAnim:Play() -- Animation finishes playing a noticeable amount quicker than the wait() time, despite having its speed changed to 0.75
    reloadAnim:AdjustSpeed(reloadAnim.Length/reloadTime.Value) -- Anim speed does change, but it doesn't appear to slow down when played??
    wait(reloadTime.Value) 
    clips.Value = clips.Value - 1 -- Clip and ammo values changes a while after the animation has finished playing
    ammo.Value = maxAmmo.Value
    reloading = false
end
Ad

Answer this question