Unwanted fading animations

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I am making a game combining multiple popular tower defense games (like BTD6, Tower Blitz or Aether Rush). I want it to be semi-retro style, so I want snappy animations. Here’s an example.

robloxapp-20240114-1846076.wmv (239.8 KB)

  1. What is the issue? Include screenshots / videos if possible!

When I play the animations, it’s all fine. The problem is with the transitions. When it switches animations, there is a fadetime for some reason.

For exemple in this video, the shooting animation plays and it is snappy, but when it attempts to transition to the idle state, there is a fade in. It’s clearly visible when buying the bottom path third upgrade. I want to have 0 linear movement.
(The janky animations are intentional by the way)

robloxapp-20240114-1835177.wmv (5.5 MB)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried integrating the animationTrack:Play(0.01) solution I saw in a post having the same problem. I have a function to play an animation at a set speed. The other arguments are for stopping any other animations.

function playAnim(playedAnim, speed, stop1, stop2, stop3, stop4, stop5, stop6, stop7)
	playedAnim:Play(0)
	playedAnim:AdjustSpeed(speed)
	if stop1 then stop1:Stop(0) else return end
	if stop2 then stop2:Stop(0) else return end
	if stop3 then stop3:Stop(0) else return end
	if stop4 then stop4:Stop(0) else return end
	if stop5 then stop5:Stop(0.01) else return end
	if stop6 then stop6:Stop(0.01) else return end
	if stop7 then stop7:Stop(0.01) else return end
end

Works fine, one animation plays and the others stop. I set all play and stop parameters to 0.01, and then 0. There’s still a fade in, so that’s not good. All my animations are played through this function, so that’s certainly the problem.

Any help would be very appreciated! Thank you all again.

The only scenario I can think of that could feature animation fading is something like this:

→ Idle animation plays
→ Shoot animation plays, but idle animation isn’t stopped
→ Shoot animation finishes naturally, fades out back to already playing idle animation

Really all I can ask is are you using playAnim() to stop the shoot animation after it’s played for the desired time? If yes, then I’m confused, and I’d like to see the code that’s using playAnim().

While I’m here, I’d like to suggest some code changes.

function playAnim(playedAnim, speed, ...) --// Passing in animations to stop as varargs
	for i,v in pairs({...}) do v:Stop(0) end
	playedAnim:Play(0)
	playedAnim:AdjustSpeed(speed)
end
1 Like

Hello, thank you for responding to my post, I extremely appreciate it!

Regarding your statement on stopping already stopped animations, I had it in my script. Here is the part of the code that plays the idle animation when the shooting animation has finished.

--////////////BEFORE//////////////
--stuff

	animation2.Stopped:Connect(function()
		playAnim(animation1, 1, animation2)
	end)

--stuff

--/////////////////NOW//////////////////
--stuff

animation2.Stopped:Connect(function()
--animation2 would have already been stopped, so no need to stop it again
	playAnim(animation1, 1)
end)

--stuff

By the way, animation1 is always idle and animation2 is always shooting. It’s the same with every single tower.

Also, I want to thank you for the playAnim function changes. My old method was very sloppy. I would have never guessed using pairs without you!
Unfortunately, if I put no arguments in the third parameter (which is an array), it throws an error. This is because ipairs/pairs do not work on nil, so here was my solution.

function playAnim(playedAnim, speed, stopAnims)
	if stopAnims then
	for i, v in ipairs(stopAnims) do
		v:Stop(0)
	end end
	
	playedAnim:Play(0)
	playedAnim:AdjustSpeed(speed)
end

Unfortunately (again), it still doesn’t work the way it’s supposed to. There are still linear movement.

I do think that your explanation is very logical and probably true. It would make much sense if it was really the case, but we can’t see if it’s the right path or not.

Thanks for helping me improve my code though! I’m still looking for a solution.

Here’s a “quick” little update on that situation. I’m hopeful it can be useful :

I made a new tower that deals damage in a different way. The tower (called “sword”) charges before attacking, basically meaning there are 3 animations: idle, attack and charge.

Of course, the animations are not working correctly. I’m not a total expert at animations so it might be an error on my end.

Here are some of the animations used (All keyframes are set to constant, meaning there are no linear movement)

robloxapp-20240119-1917509.wmv (1.6 MB)

Here’s a game with the sword tower. By the way, the unupgraded sword has a fast charging speed. Roblox Studio recorded the game with a low framerate, meaning it looks like there are linear movement when charging. I will change it, but that is not the focus right now.

Unfortunately, the attacking animations (See the first video at 30 second) are not the same as the in the game. It’s like if it was smoothed and the weight was reduced. Here’s the video.

I had to compress it because the file size was too big. “The Decimator” 500 sword upgrade makes charging very slow, so I will fix it, but again, not the focus.

Heres the code that does the animation code thingies

playAnim(animation3, tower:GetAttribute("ChargingSpeed"), {animation1, animation2})
animation3.Stopped:Wait()	
playAnim(animation2, 1, {animation3})

Should I remove {animation3}?

Again, any help would be extremely appreciated or anything, really. I have been trying to resolve this issue for a week. Thank you again!

Is this abandoned? There’s no one responding to the post.