In my game I have one game object (a sphere) that I control in order to move it on a board (its a board game).
In this objects control script, there is a var: boolean (false by default) that under certain conditions becomes true for 5 and then reverts to false.
While the bool is true (for those 5) I want to have a prefab (its an empty game object with just a collider with a certain tag) that I have in my scene, instantiated on my sphere and follow the spheres position.
I put this if statement in the spheres script:
if (boolTrue) {
Instantiate (colliderObject, transform.position);
}
The collider object has a script of its own that makes it follow the sphere and get destroyed after 5.
The problem is that I put the if statement above, inside an update function in the spheres script, the collider object gets instantiated maaaaany times (every frame I suppose).
Is there an obvious way (that I am not aware of, being a newbie) of making the collider object instantiate only once if the boolean becomes true?
I should probably use a different function to instantiate the colliderObject.
Thanks and have a happy new year!
OK now you made me look silly!!! LOL - thanks a bunch Ejlersen!
– schwertfischHehe, no problem :)
– Ejlersen