Adventure Creator  1.79.1
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2022
AC.Parallax2D Class Reference
Inheritance diagram for AC.Parallax2D:

Public Types

enum  HorizontalParallaxConstraint { Left, Right }
 
enum  VerticalParallaxConstraint { Top, Bottom }
 

Public Member Functions

void UpdateOffset ()
 

Public Attributes

float depth
 
bool xScroll
 
bool yScroll
 
float xOffset
 
float yOffset
 
bool limitX
 
float minX
 
float maxX
 
bool limitY
 
float minY
 
float maxY
 
ParallaxReactsTo reactsTo = ParallaxReactsTo.Camera
 
Transform transformToReactTo
 
HorizontalParallaxConstraint horizontalConstraint
 
VerticalParallaxConstraint verticalConstraint
 
SpriteRenderer backgroundConstraint = null
 

Protected Member Functions

void Awake ()
 
void OnEnable ()
 
void Start ()
 
void OnDisable ()
 
virtual void Initialise ()
 

Protected Attributes

float xStart
 
float yStart
 
float xDesired
 
float yDesired
 
Vector2 perspectiveOffset
 

Detailed Description

When used in 2D games, this script can be attached to scene objects to make them scroll as the camera moves, creating a parallax effect.

Member Function Documentation

◆ UpdateOffset()

void AC.Parallax2D.UpdateOffset ( )

Updates the GameObject's position according to the camera. This is called every frame by the StateHandler.

Member Data Documentation

◆ depth

float AC.Parallax2D.depth

The intensity of the depth effect. Positive values will make the GameObject appear further away (i.e. in the background), negative values will make it appear closer to the camera (i.e. in the foreground).

◆ limitX

bool AC.Parallax2D.limitX

If True, scrolling in the X-direction will be constrained

◆ limitY

bool AC.Parallax2D.limitY

If True, scrolling in the Y-direction will be constrained

◆ maxX

float AC.Parallax2D.maxX

The maximum scrolling position in the X-direction, if limitX = True

◆ maxY

float AC.Parallax2D.maxY

The maximum scrolling position in the Y-direction, if limitY = True

◆ minX

float AC.Parallax2D.minX

The minimum scrolling position in the X-direction, if limitX = True

◆ minY

float AC.Parallax2D.minY

The minimum scrolling position in the Y-direction, if limitY = True

◆ reactsTo

ParallaxReactsTo AC.Parallax2D.reactsTo = ParallaxReactsTo.Camera

What entity affects the parallax behaviour (Camera, Cursor, Transform)

◆ transformToReactTo

Transform AC.Parallax2D.transformToReactTo

Which GameObject affects behaviour, if reactsTo = ParallaxReactsTo.Transform

◆ xOffset

float AC.Parallax2D.xOffset

An offset for the GameObject's initial position along the X-axis

◆ xScroll

bool AC.Parallax2D.xScroll

If True, then the GameObject will scroll in the X-direction

◆ yOffset

float AC.Parallax2D.yOffset

An offset for the GameObject's initial position along the Y-axis

◆ yScroll

bool AC.Parallax2D.yScroll

If True, then the GameObject will scroll in the Y-direction