Difference between revisions of "Camera2dFollow"

From Headbone Creative
Jump to: navigation, search
(Initial page)
 

Latest revision as of 22:44, 14 April 2013

This script is designed to be used on 2D games. Assign a target in the editor (generally the player), and it will follow the target around the world on the X and Y axis.

Contents

[edit] Public Variables

Below are all of the variables that may be changed in the editor.

[edit] Following the target

These control how the camera follows an object (movement on the X and Y axis).

[edit] target : GameObject

This is what the camera will follow. Usually, it is the player.

[edit] playerTag : String

This is the name of a tag. If the target is null when this script is started, and this string is set, the script will attempt to look up a game object with this tag and set it as the target. See: GameObject.FindWithTag

[edit] min : Vector2 and max : Vector2

These are used together, to constrain when the camera will start following the target. This allows the target to move around the middle of the screen without the camera constantly moving, if desired. The units are in pixels. If alwaysCenter is set, these values are ignored.

[edit] alwaysCenter : bool

If this is enabled, the camera will continuously adjust itself so that the player is at the middle of the screen.

[edit] followSpeed : float

This defines how fast to move the camera towards the player.

[edit] Zooming in and out

These control the camera movement on the Z axis.

[edit] canZoom : bool

If this camera can zoom in to the object or not.

[edit] minDistance : float

The minimum zoom distance.

[edit] maxDistance : float

The maximum zoom distance.

[edit] distance : float

The starting/current zoom distance.

[edit] zoomRate : float

How fast the player can zoom in or out.

[edit] zoomDampening : float

The rate at which the forward/back movement of the camera will go when the target moves.

[edit] distanceScrollAxis : string

The Input axis to query for zooming. Default: Mouse ScrollWheel

[edit] Examples

This camera is used in the Sidescroller Demo. A prefab of this camera is also provided in the toolbox.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox