- Home /
Disable Mouse click
Hello,
So basicly in my game i have a enviroment, i'm using the proton angrybots example, and i'm going to add a giant cube on my enviroment (invisable and no collider) so basicly if your in the cube you cant click the left button, i was wondering if anyone could help me with this, and when your out of the cube you can fire.
I got this code from another answer maybe it will help?
bool disableFiring = false;
float firingDisableDuration = 5.0f; // or whatever time you want
void MouseButtonPressed() { if( !disableFiring ) { Fire(); disableFiring = true; Invoke("EnableFiring", firingDisableDuration ); } }
void EnableFiring() { disableFiring = false; }
Answer by whydoidoit · May 27, 2012 at 12:22 PM
Well the code you list is designed to do autofire with a delay - but it would still work. Just set disableFiring when you are in the cube. Aren't you going to want a collider for that though? Maybe on a different layer so it doesn't affect your bullets?
Would to use still be able to walk out of the box?, it's quite a big map and i want only a small part to have guns enabled
So long as you set the collider of the box to be in a layer that the character controller ignores