This page explains how to add parallax and repeating background elements to your game.

Introduction

The Infinite Runner Engine includes two very useful classes to have a background move in parallax (where background elements move at different speed to give a depth impression). It’s also a background repeater, which is especially useful when working with endless games. Both of these classes use the LevelManager’s speed as a factor. So the faster the whole level goes, the faster these move.

Parallax

If you add this component to an object in your scene, you’ll be able to specify a movement direction, and a speed. At runtime, your object will be duplicated, and both the object and its copy will move on that axis at the specified speed. When the object reaches a distance from its original position equal to its length, it (or its copy) will be repositioned so it gives the impression of an infinite object. For this to work though, you’ll want to have an object whose length covers the size of the scene view on screen.

ParallaxOffset

Add this class to an object and it’ll move in parallax based on the level’s speed. This method moves the texture, not the object. It doesn’t work for non-2D objects.