How to make an endless object? (3D-Object Plane)

Hello, im new as you can read in the title.
I want to make some type of endless runner but i only know how to scale the 3D objects.

Is there any way i can make the 3D Plane endless? Or always generate a new plane so i can move on it endlessly?

LG-David

Hi and welcome!

It is not possible to make an object infinitely large, however it is possible to automatically and seemlessly spawn as many of them as you need. If all you need is a flat plane, then just making it very long is probably the easiest solution. If the plane truly needs to be infinite, then you need to build some kind of “world generator”.

The idea would be as follows:

  • Create some plane and make it, for example, 100m long
  • Create a prefab from that plane
  • Reference this prefab in your spawner / manager script
  • Whenever you are at a multiple of 100m in your run direction, Instantiate() a new prefab plane in front of you

The above is the most simple version, so start with that. As you probably will notice, currently we are only spawning a new plane, after reaching the end of the old one. For most intents and purposes, this is not good enough and very noticable.
As such, you will want to introduce some variable for your “view distance”, and then spawn a new plane, as soon as your position plus view distance surpasses a new multiple of 100m. That way there seemingly is always a path in front of you. Dont forget to spawn all planes in view range initially tho :wink:

After you are done with that, you basically have an infinite runway to walk over. However, you will sooner or later run into problems since you keep on creating gameobjects. If you can only move forwards and not look back, then Destroy()'ing the planes behind you is a quick and easy solution to that problem. If you are planning to build this for mobile, then a more proper solution would be to implement a simple form of object pooling, but i’d start by putting one foot in front of the other when you are new. Which is also why i (hopefully) made an easy step by step bullet point list above and then tried to explain what problems and potential solutions follow after that.

This is actually similar to how procedural worlds are being generated, just that that would be a bit more complex (both in having more complex terrain, as well as generating it in more than one direction).
In both cases the idea is to spawn the world around the player in such way that he does not notice.

Hope this helps!