Other Highly easy solution .... I'm a beginner after all xP
How to control the amount of Instantiated prefabs?
Hi there!! ^^ I'm trying to do a Touch to move game and thanks to the user JeevanjotSingh i figure out that i could Instantiate a Trigger Collider and set it as a "Destination" for the character, and then destroy it on contact (This last one ... is a good idea to approach the issue? Any advice on this would be totally welcome) but i'm stuck at "controlling" the quantity of prefabs .. i was thinking on using a For loop but it doesn't seems to work. What should i do? Because i am just infinitely spawning colliders xP
Answer by 13yearoldceo · Oct 18, 2015 at 04:44 PM
well if i was you i would put a tag on the instantiated prefab then create a function that tracks the amount of tags in the scene like gameobject.findgameobjectswithtag[] then if your trying to limit the amount of prefabs make an if statement with the array you get from gameobject.findgameobjectswithtag[].
This is so awkward! xO I was Hard-Coding everything when it was this simple!! .-. hahahha cannot believe it!! xP ... This is what how it feels to be a novice! xP
f(mvObjectiveCount == 0 || mvObjectiveCount > 1){
Instantiate(moveObjective, hit.point, Quaternion.identity);
mvObjectiveCount++;
}