- Home /
Spawn Ground right next to current ground
I have a ground object right now and I'm trying to figure out how to instantiate more when the camera can "see" the end of the current ground. I wanted to make the ground spawn seamlessly right next to my current ground and keep doing that each time the camera can see the edge of the ground it is on. How would I go at accomplishing this? I was thinking about using the cameras position and then checking it to see if it is a certain distance away from the end of the ground, but I want to be able to do this for each ground that is instantiated as well
note I scaled the far clipping plane down to 50, so it can see up to 50 units away
Answer by leoxs · Mar 03, 2015 at 09:05 PM
Let's say D is the distance from the center of the plane to the edge, and C the distance in XZ from camera to center of the plane. You will need to find playing the max C to see the edge, then is easy to find a formula using C, D, resolution and FOV (if you need that). You will need to tell the camera that there is a new ground so she can use the same formula, and you do that in the ground script when spawns.
Don't forget to check C in every update of the camera.
Sorry, I'm noob, and not a too good english speaker, but maybe it can help you.
Your answer
![](https://koobas.hobune.stream/wayback/20220613184902im_/https://answers.unity.com/themes/thub/images/avi.jpg)