Whenever Disabling A Collider2d, It still exists in the game.
I've been working on a game for a bit now and I've come across an issue. It's in a 2D game,
I'm working on a mechanic that allows the player to roll whenever they press shift, I've got a public void that activates in the if statement, Here's the void
public void Rolling() { IsRolling = true; // sets rolling to true RGB2D.freezeRotation = false; // Makes the rotation changeable GetComponent<SpriteRenderer>().sprite = BarrelRoll; // Sets the sprite for when its rolling BottomCollider.enabled = false; // Disables circle at the bottom of the Box TopCollider.enabled = false; //This is what isn't working. It's disabling the top Capsule Collider RollingCollider.enabled = true; // Sets the CircleCollider2D to true controller.enabled = false; // Disable movement runSpeed = 0; // Disable movement }
The else for the statement is
GetComponent().sprite = Barrel; //reset sprite controller.enabled = true; // Allow movement RollingCollider.enabled = false; //Turn off circle collider for rolling TopCollider.enabled = true; //enable regular colliders * BottomCollider.enabled = true; //enable regular colliders IsRolling = false; // not rolling runSpeed = 40; // reset run speed RGB2D.rotation = 0; // revert rotation to 0 RGB2D.freezeRotation = true; // Freeze rotation
The main issue with all this is whenever I start the game and try to roll, The capsule collider is still active. I had it as a box collider earlier and still had the same issue. In the inspector it shows that everything is disabled except for the rolling Collider, whenever the shift key is pressed. I've gone through the inspector and triple checked to make sure all of the public colliders were set to the right thing. The capsule seems to still exist and is locking the rotation as well as removing the ability to roll.
Any help would be very useful and I thank you in advance.