I want to make a punch animation that has 50/50 odds of being either a left or right punch. It works just fine, other than whenever it picks the same fist twice in a row, it snaps into place. I’ve severely exaggerated it in this gif by making it move the player forward, to display this issue. https://gyazo.com/edc496a28692851e7943b3c66dc9b967
I absolutely do not know what to do. The script instantly stops whatever other animation is going on in relation to this punch (i.e animation for opposite fist) without stopping the main one, cause it’s gonna be reset by the :Play() function anyways. I’ve tried adding a Stop() to it with a .Heartbeat:Wait() connection and it did not change a thing. How do you fix this?
Does this behaviour occur when you don’t spam the punches? It may be due to not finishing the animation playback, and having to play it again, so it’s possible that it compensates for the time of the other animation not finishing.
Mathematically, my theory is that if the time left for the current animation is some time t1, and you play the same animation again with total time t, then the actual playback may be trying to do the rest of the animation from t1, and the next animation, all in t time (not t + t1 time). So really, it is playing your animation slightly faster → (t1 + t)/t = keyframe multiplier that would cause the keyframes to be at different “apparent” times than they otherwise would.
But that’s just a theory, hopefully someone with more knowledge can verify or identify what the problem is.
When you spam punches there’s a small window where the opposing fist is raised in a defensive stance. It’s usually filled in with an idle animation with both fists raised but it makes it slightly harder to see the problem. So when I spam it, the animation isn’t over.
Edit: I see what you mean. I’ll try setting the weights up for the initial frames, see what that does.
I raised the cooldown of the attacks, result is still very strange. What’s extremely odd is that it behaves exactly as expected when the fist switches side, therefore it is most likely not an issue with it trying to “autofill” from the previous animation as it would’ve also been taken into account with the alternate animation. Result would’ve been that the issue would persist even when the animation was the opposite one. https://gyazo.com/61e3b42e5b644a9bd47951ad71fdcc3d
That’s not what I meant exactly. Sorry if I was a little unclear before.
I think that the queue for the specific animation is not refreshing properly - switching requires a different animation, so you don’t observe the “snappy” action while changing fists.
Also, I meant to ask if you could wait a few seconds before punching again - if the snapping continues then it is most likely a cooldown problem, or some queue timer, or something I’m not aware of. I’ll keep thinking about it, though.
I had raised the cooldown to .6 seconds, that is time for the animation to play before another 50/50 animation can be played.
I can confirm that the cooldown is completely fine. The attack going out faster than usual is purely a visual trick from the animation snapping in place and skipping most of the buildup.
Note: I know the while loop is bad practice but it’s only for when players join in and then never takes action again, so it’s not worth messing with events just do fix this one tiny thing.
Sorry for late reply, the same animation cannot overlap itself. You’d need to load a 2nd animationtrack with the same animation in order to fade out of the previous animation and into the new one, otherwise it cannot fade from itself to itself and snaps back to the start of the animation.