Infinite Level

I’m concepting a scrolling game with infinite procedural content (like a side-scroller or Doodle Jump) and trying to decide on the best way to construct it. I am considering two options.

  1. Move the character and camera, keep the level fixed.
  2. Move the level, keep the camera and player fixed.

I’m leaning towards option 1 but I do worry that I may hit a distance far enough out to start causing floating point errors. Is there a limit on distance from the world origin that objects can exist? Does the physics system get less accurate when it is at extreme distances from world origin?

mod edit: removed old link

May or may not help but i will share when I did for an endless sidescroller that worked fine.
I let it run for about and hour with no slowdown for testing too.
The whole thing kind of functions like treadmill

The character moved and there was about 10 different “chunks” of level presets set off to the side out of site (could have been prefabs too but, I wanted everything loaded at start)

Basically my guy just kept running and had a collider attached to him way in front off screen that was just a trigger.
When the trigger touched the end of the “chunk” a new one spawned via random selection using a very small array script.
All this of course happening far enough in front not to be seen.
Then a timer just destroyed the chunk about 10 seconds later (when it was far enough behind)

With the array triggering your level elements you can set it so the farther you get the more the harder ones spawn too.

These chunks had platforms collectables and everything already set up too.

RobotsVsWizards has the right idea. Think treadmill. Scroll textures, think small. There are many creative way to achieve the illusion of an infinite world.

Here is good tut on your prob

http://catlikecoding.com/unity/tutorials/runner/

I decided to keep the camera and player “relatively” stationary. This I believe is better as it makes positioning new items, incoming enemies, rewards etc easier as Vector3.zero is now a common point. Basically, by keeping the player and camera stationary, it keeps things a lot less messy. At least for my cause.

I just instantiate items off screen. When they are ready to be used, place the main mng transform at Vector3.zero. Inside the sprites are ported into scene. You can see what I mean via any of my signature links.