I am working on a game that relies heavily on animations and keyframes. I just created a quick, 1/5 of a second punching animation. The final frame is named “End.” I use the KeyframeReached event and the keyframe name to determine when the animation is done so that the user can initiate another animation. It works PERFECTLY when the animation has properly named keyframes.
But then disaster strikes at random times.
Sometimes, instead of “End,” I’m being given “KF0.2” at the final frame. I know this because I now have my LocalScript printing each keyframe name on KeyframeReached. Below is the Output that I got on my last test.
[EDIT]
By the way, I have three other animations, each 4/5 of a second long. After nearly thirty tests each, none of them had this bug occur. It seems to only happen with this shorter animation. It happens often. Usually the first time I use it, but sometimes it works correctly three or four times.
Are these all the same animation? Can you print out which animations the reached keyframes are part of? It just seems very odd that the name of the keyframe would change at runtime.
Is there a test place that you are using to test this? Can you put a link to it, if you have one?
[quote] Are these all the same animation? Can you print out which animations the reached keyframes are part of? It just seems very odd that the name of the keyframe would change at runtime.
Is there a test place that you are using to test this? Can you put a link to it, if you have one? [/quote]
The longer ones are all separate. The one animation that is breaking, the .2 second-long animation, is just one. I’ve tried re-uploading it several times, as well, and still get a problem. I just uploaded another animation of .2 seconds, and it is almost an exact replica of the one that is breaking, just mirrored (left hand instead of right), and it works fine. I plan on trying to remake the right one soon, but, I believe it’d be good to have this bug fixed.
The animation that is breaking is this one, and you can see the game in action here. To play the animation, just press ‘f’ on your keyboard. If it gets stuck, resetting should let you try again.
Oh, and, by the way, yes. All of the Output that I showed you in that gyazo image was, in fact, from the same animation. Each time it said “End” was the end of the animation running one full circuit. The animation is NOT looped.
Ok, thanks to your reproduce case, I was finally able to track down the case where these bad end key frames were being created. I’ve updated the Animation Editor plugin and it shouldn’t happen in the future. To fix your particular animation, you’ll need to reopen it. You’ll notice that there are now two key frames at 0.2 in time. You’ll need to delete the one named KF0.2 and then re-export it. That should fix your issue.
It was a bug in the Animation Editor plugin. I had reports of it before, but I couldn’t reproduce it easily, so it was hard to fix. By setting the animation length to 0.2, it happened every time, so it was easy to tell if my fix actually fixed the issue.
The updated, fixed plugin is now available through the plugin manager.
But then I tested again, and, without changing my script at all, the KeyframeReached event is NEVER FIRING now. I am not getting ANY keyframe names printed - at all! With ANY of my animations! Below is the chunk of my code handling this (keep in mind, I didn’t change my code AT ALL in between when it worked and now, but I’m showing for debugging purposes)
local animTrack = character.Humanoid:LoadAnimation(animInfo.Animation)
animTrack.KeyframeReached:connect(function(keyframeName)
print(keyframeName)
if keyframeName == "End" then
character.Humanoid.WalkSpeed = ws
game.ReplicatedStorage.LocalEvents.CharacterAnimationEnded:Fire(animName)
game.ReplicatedStorage.RemoteEvents.PlayerCharacterAnimationEnded:FireServer(animName)
end
end)
With all the problems regarding how to detect when an animation stops (and is not looped), I think you’d be better off with this:
→ Click “Show hidden members” on the events for AnimationTrack.
I have tested the .Stopped-event in studio, and it works fine (so the description at the wiki seems quite misleading). Certain it’ll work online too.
[quote] With all the problems regarding how to detect when an animation stops (and is not looped), I think you’d be better off with this:
→ Click “Show hidden members” on the events for AnimationTrack.
I have tested the .Stopped-event in studio, and it works fine (so the description at the wiki seems quite misleading). Certain it’ll work online too. [/quote]
Really, it works. I see why you don’t want to use deprecated methods/properties/functions, but with all these issues, I think it’s a plausible suggestion. Not that Workspace or :Remove has been removed completely over the past years.
While you’re right - deprecated items are rarely removed on ROBLOX, I can’t do that to my game…It was working earlier today perfectly. Something changed somehow.