So I’m try make an endless runner and I want the rocks to spawn randomly one at a time or two at a time. Whenever they spawn 2 at a time they’re either at two different positions(How I want it) or they’re at the same spot overlapping each other(what I don’t want). Here’s the code for spawning the rocks:
Create a boolean array with size 3, one for each of your spawn points. Whenever you spawn a rock at the n’th spawn point, set n’th element of the boolean array to true.
When you are spawning a rock, have a branch that checks if that spawn point is occupied. If it is occupied, attempt to spawn again. (Until you get a success).
Or as another idea, instead of trying to spawn until it succeeds, always attempt to spawn 2 rocks(By removing the first switch), but whenever the spawn point is occupied you just dont spawn the second rock, so you have both 1 rock segments and 2 rock segments.