- Home /
Collider randomly enabling and disabling for a split second after an animation
I am currently making a fighting/street fighter type 2D game. So far everything has been running smoothly except for a slight glitch that I can't seem to figure out. Currently I have 8 identical fighters(distinguished by color) with a single fighter controller script that they each use to move and attack.
I created a punching animation for my red fighter and used Unity's animation window to enable a circle collider on my fighter's fist when his arm is fully extended. The only time this circle collider is enabled is on a single frame in the jab animation where the arm is fully extended and I made sure to set the circle collider to disabled at the start of every animation(as well as disabled by default).
For whatever reason, the circle collider enables and disables for a split second after transitioning from my jab animation to any other animation and I can't figure out why. This makes it so that the last punch from the fighter always triggers two collisions, when it should only trigger one.
Here is a photo of the split second that this occurs:
.
It says that this is happening in the second frame of my Idle Animation however this does not appear in the animaton window when the animation is previewed.
I decided to look at the animator window and It almost appears as though two animations are playing at the same time:
I think that this may be where this glitch is coming from. I was wondering if anyone knew what was happening here. Could the error lie in the fact that the animation has an exit time? If so, is there any way that you know of that I could potentially fix this?
Thanks for reading this post, I'll update the thread if I figure it out before I get a response.
what method do you use to enable/disable the collider at the right time? Animation events? If so check if thoses events are called correctly or at unexpected times. if i remember correctly an animation event will also trigger during state transitions.
You are correct in that I enable and disable in animation events. I think the problem is in fact that it seems to be triggering either during a transition or at the beginning of different animation. Thanks for the idea, ill try looking for ways to prevent this from occurring after the attack is supposed to stop.
Your answer
Follow this Question
Related Questions
Character Hit Animation play endlessly 2 Answers
how to make a irregular ground or slope,About irregular terrains and slopes 0 Answers
Collider lets object through 0 Answers
Animation Moving Sprite Away from Collider 0 Answers
Root Motion vs Collider issue. How to stop animation moving char through a collider? 1 Answer