Hey guys,
I am looking to turn off the box collider 2D of my characters weapon. Currently I have it to where: When the player left clicks, it will activate the box collider and when the player releases the left click, it turns off the box collider. I want it to where it activates it on left click and automatically turns it back off no matter what. I do have a cool down system to where the player can’t click for another second, but as of now the player can just hold down the mouse key to simply avoid the cool down.
This is all within the same script: PlayerSM
//Where player activates mouse click
void MeleeHandler ()
{
if (Input.GetKeyDown (KeyCode.Mouse0) && meleeCDbool == false)
{
MeleeBox.SetActive (true);
meleeCDbool = true;
}
if (Input.GetKeyUp (KeyCode.Mouse0))
{
MeleeBox.SetActive (false);
}
}
---------------------------------------------------------------------------------------------------------
//Cooldown for the attack
void Timers()
{
if (meleeCDbool == true)
{
meleeCD -= Time.deltaTime;
if (meleeCD <= 0)
{
meleeCDbool = false;
meleeCD = MaxMeleeCD;
}
}
}