Hello, I am working on my 2D game where I have my main camera moving horizontally from left to right. Instead of instantiate all game objects at the start of the scene, I want to spawn them as the camera moves close to their x positions.
I have a JSON like this to store the position of each GO that need to be spawned during runtime:
{
"apple":{
"xpos":13,
"ypos":2
},
"banana":{
"xpos":40,
"ypos":2
},
"pear":{
"xpos":25,
"ypos":2
}
}
Does anyone have a solution to trigger the instantiation when the camera’s x position is equal or greater than the x position of each of the items? Suppose the camera starts moving from a x position of 0. Thank you in advance!