- Home /
Checkibg Rigidbody2d and component problems
So I have two scripts one is for moving the player left and right with A or D or the left and right arrow keys, and the second one is an attack script” and what it does is plays an animation and enables the PolygonCollider2d if the G key is being held. But then I decided that I don’t want the G key to do anything if the player is moving, so I made this code in the FixedUpdate method.
if (MyRigidbody.velocity != Vector2.zero) { myPolygonCollider2d.enabled = false; }
It did what it is suppose to do but if you press A or D/ left and right arrow keys fast and press the G key while doing this the PolygonCollider2d will enable for a split second and you can do this as many times as you want, how can I stop the Polygon Collider2d from enabling when you perform this unwanted action.