I have not found any answers on here to help me out so I just thought I would ask. Hopefully I am not repeating a question with an answer already, I just haven't found it.
I have a door that needs to be opened after you shoot 3 targets. I have an inventory that keeps track of doors hit, and when you shoot the target it is destroyed and adds 1 to the inventory. I am trying to make it so once the inventory is at 3, the door will open. I already have a working door script so there is no problem on that, so I am just using print("Door is opening!"); to let me know everything is working properly.
//This script is used to open a door when the three targets are hit
function update ()
{
if(GameManager.targetsHit == 3)
{
print("Door Opening!");
}
}
//Im using print right now just to know if this is working correctly. Right now if I shoot all the targets, it doesn't print.
// This script keeps track of stats, inventory, etc...
static var greenKey: int = 0;
static var targetsHit: int = 0;
//This script destroys the game object when trigger object is hit
function OnTriggerEnter ( other: Collider )
{
Destroy(gameObject);
GameManager.targetsHit ++;
print("Target Hit!");
}
As of right now, the targets get destroyed and the print comes up and says that the target was hit. So it should be adding to the inventory, and the door should open once it reaches 3. . . but it is not. Please help. Thank you in advance!