Logo
 All Classes Files Functions Variables Enumerations
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
DynamicCamera Class Reference

Classes

class  ModeSettings
class  MoveSettings

Public Types

enum  CameraMode {
  VelocityTracking, TargetTracking, Down, Up,
  Right, Left, Forward, Back,
  Overhead, Beneath, ManualAbsolute
}
enum  MoveMode { Instant, Linear, Angular }
enum  RotationMode { Instant, Interpolated }

Public Member Functions

void SetPrimaryTarget (Transform t)
void SetTrackingTarget (Transform t)
void SetMovementSpeed (float spd)
void SetCameraMode (CameraMode mode)
void SetCameraApproach (MoveMode mode)
void SetManualAngle (Vector3 v)
void SetIdealDistance (float dist)
void SetUpperDerivation (float d)
void SetLowerDerivation (float d)
void SetRotationMode (RotationMode m)
void SetRotationSpeed (float f)
Transform GetPrimaryTarget ()
Transform GetTrackingTarget ()
float GetMovementSpeed ()
CameraMode GetCameraMode ()
MoveMode GetCameraApproach ()
Vector3 GetManualAngle ()
float GetIdealDistance ()
float GetUpperDerivation ()
float GetLowerDerivation ()
RotationMode GetRotationMode ()
float GetRotationSpeed ()
void SetMinimumDistance (float d)
float GetMinimumDistance ()
void SetMaximumDistance (float d)
float GetMaximumDistance ()

Public Attributes

Transform mainTarget = null
ModeSettings modeSettings
MoveSettings movementSettings

Detailed Description

This is a camera capable of following an arbitrary target object in many ways. It is best used when it is important to keep some target in the center of the view. A racing game, platformer, or space shooter for example.

To use it simply apply the dynamic camera script directly to a camera, and set up the variables for the behavior you desire. The operation is entirely automatic one runtime begins, though you can easily change any of these modes/variables during runtime.

Member Enumeration Documentation

This enumeration describes all possible camera modes.

The camera tries to approach some ideal position, which is calaculated based on the selected mode. All of these modes, except otherwise noted, operate relative to the rotation of mainTarget, not absolute directions. To set to an absolute direction, use ManualAbsolute mode.

See Also
ModeSettings.cameraMode
Enumerator:
VelocityTracking 

Positions the camera to look where the mainTarget is going. Requires that the main target has a Rigidbody.

TargetTracking 

Positions the camera to keep some trackingTarget in the line of sight, while tracking the mainTarget.

Down 

Positions the camera above the main target, looking down.

Up 

Positions the camera below the main target, looking up.

Right 

Positions the camera to the left of the main target, looking right.

Left 

Positions the camera to the right of the main target, looking left.

Forward 

Positions the camera behind the main target, looking forward.

Back 

Positions the camera in front of the main target, looking back.

Overhead 

Positions the camera behind and above the main target, looking at a 45* forward/down angle.

Beneath 

Positions the camera behind and below tha main target, looking at a 45* forward/up angle.

ManualAbsolute 

Positions the camera at an angle defined by the user. This is in absolute world space, not relative to target rotation.

This enumeration describes all possible movement modes for the camera

This selection defines the manner in which the camera will move. As a general note, LINEAR will occasionally get stuck if it can not pass through what is in the direct line of sight. If this occurs, try using ANGULAR instead, as it adopts a more resilient form of movement.

See Also
MoveSettings.movementMode
MoveSettings.moveSpeed
Enumerator:
Instant 

The camera will move to the ideal position instantly, with no travel time. This is a non-damping mode.

Linear 

The camera will move towards the ideal position in a strait line. Utilizes Lerp to achieve this.

Angular 

The camera will move towards the ideal position on a curve. Utilyzes Slerp to achieve this.

This enumeration decribes the possible rotation modes of the camera

The camera can either look at the target instantly, or take time to achieve ideal rotation.

See Also
MoveSettings.rotationMode
MoveSettings.rotationSpeed
Enumerator:
Instant 

The camera will immediately look at the main target with no delay

Interpolated 

The camera look at the target by interpolating between the current rotation and the ideal rotation

Member Function Documentation

MoveMode DynamicCamera.GetCameraApproach ( )

This returns the current movement mode of the camera

Returns
The current movement mode
See Also
MoveMode
MoveSettings.movementMode
SetCameraApproach
CameraMode DynamicCamera.GetCameraMode ( )

This returns the current camera mode

Returns
The current camera mode
See Also
ModeSettings.cameraMode
SetCameraMode
CameraMode
float DynamicCamera.GetIdealDistance ( )

This returns the current ideal distance from the target

Returns
The current ideal distance
See Also
SetIdealDistance
MoveSettings.idealDistance
float DynamicCamera.GetLowerDerivation ( )

This returns the current lower derivation

Returns
The current lower derivation
See Also
SetLowerDerivation
MoveSettings.lowerDerivation
Vector3 DynamicCamera.GetManualAngle ( )

This returns the current manual angle of the camera

Returns
The current manual angle of the camera
See Also
ModeSettings.manualAngle
CameraMode
SetManualAngle
float DynamicCamera.GetMaximumDistance ( )

This returns the current maximum distance the camera can be from the target

Returns
The current maximum distance
See Also
SetUpperDerivation
GetUpperDerivation
SetMaximumDistance
MoveSettings.maximumDistance
float DynamicCamera.GetMinimumDistance ( )

This returns the current minimum distance the camera can be from the mainTarget

Returns
The current minimum distance
See Also
SetLowerDerivation
GetLowerDerivation
SetMinimumDistance
MoveSettings.minimumDistance
float DynamicCamera.GetMovementSpeed ( )

This returns the current movement speed of the camera

Returns
The current movement speed of the camera
See Also
MoveSettings.moveSpeed
SetMovementSpeed
Transform DynamicCamera.GetPrimaryTarget ( )

This returns the current primary target

Returns
The current primary target
See Also
mainTarget
SetPrimaryTarget
RotationMode DynamicCamera.GetRotationMode ( )

This returns the current rotation mode of the camera

Returns
The current rotation mode
See Also
RotationMode
MoveSettings.rotationMode
SetRotationMode
float DynamicCamera.GetRotationSpeed ( )

This returns the current rotation rate of the camera

Returns
The current rotation rate of the camera in radians
See Also
MoveSettings.rotationSpeed
SetRotationSpeed
Transform DynamicCamera.GetTrackingTarget ( )

This returns the current tracking target

Returns
The current tracking target
See Also
ModeSettings.trackingTarget
SetTrackingTarget
float DynamicCamera.GetUpperDerivation ( )

This returns the current upper derivation

Returns
The current upper derivation
See Also
SetUpperDerivation
MoveSettings.upperDerivation
void DynamicCamera.SetCameraApproach ( MoveMode  mode)

This sets the method the camera approaches with.

This modifies the moveSettings.movementMode variable. Note that arguments must be as follows: DynamicCamera.MoveMode.EXAMPLE

Parameters
modeThe new camera movement mode
See Also
GetCameraApproach
MoveSettings.movementMode
void DynamicCamera.SetCameraMode ( CameraMode  mode)

This sets the camera mode

This modifies the modeSettings.cameraMode variable. Note that arguments must be as follows: DynamicCamera.CameraMode.EXAMPLE

Parameters
modeThe new mode of the camera
See Also
GetCameraMode
ModeSettings.cameraMode
void DynamicCamera.SetIdealDistance ( float  dist)

This sets the ideal distance from the target

This modifies the movementSettings.idealDistance variable. If this value is less than zero, an error is reported and no change is made.

Parameters
distThe new distance from the target
See Also
GetIdealDistance
MoveSettings.idealDistance
void DynamicCamera.SetLowerDerivation ( float  d)

This sets the lower derivation from ideal distance

This modifies the movementSettings.lowerDerivation variable. If this is less than zero, an error is reported and no change is made. If this is greater than ideal distance, an error is reported and no change is made.

Parameters
dThe new lower derivation
See Also
MoveSettings.lowerDerivation
GetLowerDerivation
void DynamicCamera.SetManualAngle ( Vector3  v)

This directly sets the manual direction vector

This modifies the modeSettings.manualAngle variable. All non-zero vectors area acceptable. A zero vector will result in an error message and abortion of the operation. The input vector provided will be normalized before being stored.

Parameters
vThe new vector for manual camera positioning
See Also
GetManualAngle
ModeSettings.manualAngle
void DynamicCamera.SetMaximumDistance ( float  d)

This sets the maximum distance of the camera from the target

This will attempt to set the upper derivation to meet the value in the arguments. If this is not possible, a warning will be reported and the upper derivation will be set as close as possible to the desired result.

Parameters
dThe desired maximum distance from the camera to the target
See Also
SetUpperDerivation
GetUpperDerivation
GetMaximumDistance 8
MoveSettings.maximumDistance
void DynamicCamera.SetMinimumDistance ( float  d)

This sets the minimum distance of the camera from the target

This will attempt to set the lower derivation to meet the value in the arguments. If this is not possible, a warning will be reported and the lower derivation will be set as close as possible to the desired result.

Parameters
dThe desired minimum distance from the camera to the target
See Also
SetLowerDerivation
GetLowerDerivation
GetMinimumDistance
GetIdealDistance
SetIdealDistance
MoveSettings.minimumDistance
void DynamicCamera.SetMovementSpeed ( float  spd)

This sets movement speed of the camera

This method reassigns the movementSettings.moveSpeed variable. If this parameter is less than zero, an error will be reported, and the operation will be aborted.

Parameters
spdThe new camera speed
See Also
GetMovementSpeed
MoveSettings.moveSpeed
void DynamicCamera.SetPrimaryTarget ( Transform  t)

A collection of setters for nice looking code integration This sets the primary target

This method reassigns the mainTarget variable. If this parameter is null, an error will be reported, but the operation will proceeed.

Parameters
tThe transform to look at/follow
See Also
GetPrimaryTarget
mainTarget
void DynamicCamera.SetRotationMode ( RotationMode  m)

This sets the rotation mode of the camera

This modifies the movememntSettings.rotationMode variable. Note that the argument must be as follows: DynamicCamera.RotationMode.EXAMPLE

Parameters
mThe new rotation mode.
See Also
MoveSettings.rotationMode
DynamicCamera.RotationMode
GetRotationMode
void DynamicCamera.SetRotationSpeed ( float  f)

This sets the rotation rate of the camera.

This is the rate, in radians, that the camera can rotate each second. This modifies the movementSettings.rotationSpeed variable. If this is less than zero, an error is reported and no change is made.

Parameters
fThe new rotation speed
See Also
GetRotationSpeed
MoveSettings.rotationSpeed
void DynamicCamera.SetTrackingTarget ( Transform  t)

This sets the tracking target

This method reassigns the modeSettings.trackingTarget variable. If this parameter is null, an error will be reported, but the operation will proceeed.

Parameters
tThe transform to track
See Also
GetTrackingTarget
ModeSettings.trackingTarget
void DynamicCamera.SetUpperDerivation ( float  d)

This sets the upper derivation from ideal distance

This modifies the movementSettings.upperDerivation variable. If this is less than zero, an error is reported and no change is made.

Parameters
dThe new upper derivation
See Also
MoveSettings.upperDerivation
GetUpperDerivation

Member Data Documentation

Transform DynamicCamera.mainTarget = null

The Transform the camera is following

This is the primary target that the camera positions itself relative to, and looks at. If this is null, the camera is inactive. This can not be the camera.

See Also
SetPrimaryTarget
GetPrimaryTarget
ModeSettings DynamicCamera.modeSettings

This contains the camera mode settings.

See Also
ModeSettings
MoveSettings DynamicCamera.movementSettings

This contains the movement settings

See Also
MoveSettings

The documentation for this class was generated from the following file: