In endless vertical scroller games, If the camera moves vertically down, there are some objects that leave the camera view from the top. Is it possible to replace these objects at the bottom edge of the camera?
This is what I tried, by subtracting the position vectors. Which didn’t do the job the way I described above.
This might be a bit late but the code you provided put my start position to the top center of the screen. I changed it to this to get the bottom center:
var screenBottomCenter = new Vector3(Screen.width/2, 0, 0); var inWorld = Camera.main.ScreenToWorldPoint(screenBottomCenter);
You need to use Camera.ScreenToWorldPoint function which convert position from Screen to World space, so in that way you can spawn objects at the bottom edge of the camera.
See this article from unitydocs: Unity - Scripting API: Camera.ScreenToWorldPoint
for example:
var screenBottomCenter = new Vector3(Screen.width/2, Screen.height, 0);
var inWorld = Camera.main.ScreenToWorldPoint(screenBottomCenter);