Hi, I’m trying to position some titles according to how many are in frame at the same time. For instance, my character gets an ammo powerup and “EXTRA AMMO” pops up on screen for 4 seconds and dies, but I want any other instance of “EXTRA AMMO” to appear above the current prefab, so I’m adding the number of prefabs together for position information with the following code:
function instance(name : String) {
var powerupInstances = GameObject.FindGameObjectsWithTag("PowerUpTitle").Length;
Instantiate(Resources.Load(name), Vector3(0,13+powerupInstances,10-powerupInstances), Quaternion.identity);
}
The problem is that when the character gets 2 pieces of ammo within a short time period (maybe within a frame) GameObject.FindGameObjectsWithTag doesn’t return the correct number of objects in scene so the power up titles are stacked on top of each other instead of offsetting. I tried yield new WaitForFixedUpdate() and WaitForSeconds(.1) but both of those actually stop any code after it from running in the function.
What am I doing wrong here?