![]() |
DangerCamera
1.2
The most dangerous of Unity cameras. Copyright 2016-2017 Subaltern Games, LLC all rights reserved
|
DangerCamera is the most dangerous of all cameras. Creators: Seth Alter (subal) Danger Donaghey ( tern games @gma il.co mdange) Copyright 2016-2017 Subaltern Games, LLC all rights reserved. rdon aghey @gma il.co mMore...
Inherits MonoBehaviour.
Classes | |
class | DangerCameraZoomLevel |
Danger camera zoom level data. More... | |
Public Member Functions | |
virtual float | GetDistance () |
Returns the camera distance. More... | |
virtual int | GetZoomLevel () |
Returns the index of the current DangerZoomLevel in zoomLevels. More... | |
int | AddZoomLevel (DangerCameraZoomLevel dzl) |
Adds the zoom level to the list in order of defined distance parameter. Returns the index of the added zoom level. More... | |
DangerCameraZoomLevel | GetZoomLevel (int i) |
Gets the sorted zoom level. Returns the zoom level at a given index. More... | |
bool | StartTracking (Transform target) |
Begin tracking to this target. Returns true if tracking was sucessful. More... | |
void | StartTrackingAndZoom (Transform target) |
Start tracking a target and also zoom towards it. More... | |
void | StartTracking (Vector3 position) |
Track to this position. More... | |
void | TrackAndSnapMouseTo (Vector3 position) |
Track an object. Rotate the camera such that the mouse falls on top of the object. More... | |
void | StopTracking () |
Set the tracking target to backupTarget (meaning we track nothing). More... | |
bool | IsTrackingTarget (Transform target) |
Returns true if we are tracking this target. More... | |
bool | AddFramingTarget (Transform t) |
Add a framing target. Returns true if the target was added to the HashSet, and false if it is already there. More... | |
Public Attributes | |
UnityEvent | OnZoom |
Trigger this event when the camera zooms. More... | |
UnityEvent | OnWASD |
Trigger this event when player uses WASD. More... | |
UnityEvent | OnRotate |
Trigger this event when camera rotates. More... | |
UnityEvent | OnMousePan |
Trigger this event when the mouse pans the camera. More... | |
UnityEvent | OnTrack |
Trigger this event when the camera is tracking. More... | |
float | MouseAngleMinY = 23.00f * Mathf.Deg2Rad |
The minimum angle the mouse can bring the camera towards the floor. Lower numbers bring it increasingly parallel to the floor. Clamped to avoid camera inverting. More... | |
float | MouseAngleMaxY = 89.00f * Mathf.Deg2Rad |
The maximum angle of the camera. Clamped to avoid camera inverting. More... | |
bool | allowWASDPan = true |
Whether this camera listens for panning (WASD) input. More... | |
bool | allowZoom = true |
Whether this camera listens to zooming (scroll wheel) input. More... | |
bool | allowRotation = true |
Whether this camera listens to rotational (right click + drag) input. More... | |
bool | allowFraming = true |
Whether this camera will attempt to frame objects. More... | |
bool | allowMousePan = true |
Whether this camera listens to mouse pan. More... | |
float | panSensitivity = 1f |
Adjust how sensitive (fast) panning is (WASD and mouse). More... | |
KeyCode | KeyZoomIn = KeyCode.LeftBracket |
Key used to zoom in. More... | |
KeyCode | KeyZoomOut = KeyCode.RightBracket |
Key used to zoom out. More... | |
float | minDistance = 5 |
Minimal distance from camera to the floor. More... | |
float | maxDistance = 50 |
Maximum distance from camera to the floor. More... | |
float | trackZoomDistance = 6 |
When tracking and zooming, zoom to this distance. More... | |
float | zoomLerpSensitivity = 0.5f |
Lerp the distance from the camera to the floor at this rate. More... | |
bool | invertRotationX = false |
Whether to invert the x axis. More... | |
bool | invertRotationY = false |
Whether to invert the y axis. More... | |
float | rotationSensitivity = 1f |
Mouse sensitivity when rotating. More... | |
float | rotationLerpSensitivity = 0.5f |
When rotating, how fast the camera will move to follow the mouse. 0 - prevents camera rotation updates 1 - prevents camera rotation smoothing More... | |
float | mousePanEdgePercent = 0.05f |
Detect mouse panning when the distance from the mouse to a viewport edge is less than or equal to this. Must be between 0 and 1. More... | |
float | boundsX = 500f |
The x value of the bounds beyond which the camera will not pan. More... | |
float | boundsZ = 500f |
The z value of the bounds beyond which the camera will not pan. More... | |
Vector2 | boundsCenter = new Vector2 () |
The center of the bounds. More... | |
float | trackLerpSensitivity = 0.5f |
How fast camera moves when tracking. More... | |
Static Public Attributes | |
static DangerCamera | instance |
Protected Member Functions | |
virtual void | Awake () |
virtual void | Start () |
virtual float | GetBackupTargetZ () |
Returns the starting backup target z value. More... | |
virtual float | GetBackupTargetY () |
Returns the starting backup target y value. More... | |
virtual float | WASDZoomCoefficient () |
Returns the percent of the way between min and max distance from the camera focal point. This is used to modify the translation speed based on zoom level. More... | |
virtual Vector3 | TranslationToFloor (Vector3 translation) |
Returns the new direction to move the camera, modified by the camera's orientation and constrained in regards to horizontal movement. More... | |
virtual void | TrackToTarget () |
Move transform towards trackingTarget. More... | |
virtual bool | CheckLevelBoundsWhileTracking () |
Returns true if the camera should check if it is out of bounds before tracking to target. More... | |
Vector3 | GetTrackingAngledVector () |
Returns the angled vector at which the camera should track. More... | |
void | MouseRotation () |
Update the angle of mouse movement. More... | |
Vector3 | GetWASD () |
Pan with WASD. More... | |
Vector3 | GetMousePan () |
Pan with the mouse when it is close to the edges of the screen. More... | |
virtual bool | IsWithinLevelBounds (Vector3 newPosition) |
Returns true if position is within level bounds. More... | |
bool | IsRotation () |
Is the player rotating the camera? More... | |
virtual bool | IsRotationInput () |
Returns true if the user is entering the correct input for rotation. More... | |
virtual int | GetDefaultZoomLevel () |
The default zoom level for the camera. Used in WaitAndThenZoom. More... | |
IEnumerator | WaitAndZoom () |
Wait a bit, and then zoom. More... | |
virtual void | ZoomTo (int zoom) |
Set distance given the index of zoomLevels. More... | |
void | HandleZoom () |
Trigger events given the distance. More... | |
void | SetZoom () |
Sets distance based on scroll wheel movement. More... | |
virtual bool | SetDistanceByZoom (float d) |
Given a zoom increment, set the camera distance. Returns true if we are at the min or max possible distance. More... | |
virtual void | HandleTranslation () |
Handles the translation of the camera. It takes the raw translation, modifies that to fit the floor and angle, then moves only if the camera is within level bounds. More... | |
virtual Vector3 | GetRawTranslation () |
Returns the raw translation of the camera. More... | |
void | FrameInViewport () |
If we have any viewport targets and they are not within the viewport, pull the camera away. More... | |
bool | IsInViewport (Transform t) |
Returns true if the object is in the viewport. More... | |
virtual void | Update () |
Protected Attributes | |
const string | INPUT_HORIZONTAL = "Horizontal" |
const string | INPUT_VERTICAL = "Vertical" |
const string | INPUT_SCROLLWHEEL = "Mouse ScrollWheel" |
List< DangerCameraZoomLevel > | zoomLevels |
A list of all zoom levels. More... | |
Vector3 | expectedFloorPosition = new Vector3(0, -100, 0) |
The position used to calculate the raycast direction to find the camera's starting focal point. More... | |
Properties | |
Camera | Cam [get] |
The camera associated with this DangerCamera object. If DangerCamera.cam is not assigned, this will assign it first. More... | |
Transform | TrackingTarget [get, set] |
Returns the target the camera is currently tracking. Can also set the target. Always set the target here! More... | |
float | ZoomSpeed [get] |
Returns the speed at which the camera will zoom. The speed is dependent on the distance, and defined in zoomLevels. More... | |
DangerCamera is the most dangerous of all cameras. Creators: Seth Alter (subal) Danger Donaghey ( tern games @gma il.co mdange) Copyright 2016-2017 Subaltern Games, LLC all rights reserved. rdon aghey @gma il.co m
bool DangerCamera.AddFramingTarget | ( | Transform | t | ) |
Add a framing target. Returns true if the target was added to the HashSet, and false if it is already there.
t | The Transform we want to frame |
int DangerCamera.AddZoomLevel | ( | DangerCameraZoomLevel | dzl | ) |
Adds the zoom level to the list in order of defined distance parameter. Returns the index of the added zoom level.
dzl | The new zoom level being added. |
|
protectedvirtual |
|
protectedvirtual |
Returns true if the camera should check if it is out of bounds before tracking to target.
|
protected |
If we have any viewport targets and they are not within the viewport, pull the camera away.
|
protectedvirtual |
Returns the starting backup target y value.
|
protectedvirtual |
Returns the starting backup target z value.
|
protectedvirtual |
The default zoom level for the camera. Used in WaitAndThenZoom.
|
virtual |
Returns the camera distance.
|
protected |
Pan with the mouse when it is close to the edges of the screen.
|
protectedvirtual |
Returns the raw translation of the camera.
|
protected |
Returns the angled vector at which the camera should track.
|
protected |
Pan with WASD.
|
virtual |
Returns the index of the current DangerZoomLevel in zoomLevels.
DangerCameraZoomLevel DangerCamera.GetZoomLevel | ( | int | i | ) |
Gets the sorted zoom level. Returns the zoom level at a given index.
i | The index of the zoom level desired. |
|
protectedvirtual |
Handles the translation of the camera. It takes the raw translation, modifies that to fit the floor and angle, then moves only if the camera is within level bounds.
|
protected |
Trigger events given the distance.
|
protected |
Returns true if the object is in the viewport.
t | The object we want to be in the viewport |
|
protected |
Is the player rotating the camera?
|
protectedvirtual |
Returns true if the user is entering the correct input for rotation.
bool DangerCamera.IsTrackingTarget | ( | Transform | target | ) |
Returns true if we are tracking this target.
target | Transform that we might be tracking |
|
protectedvirtual |
Returns true if position is within level bounds.
|
protected |
Update the angle of mouse movement.
|
protectedvirtual |
Given a zoom increment, set the camera distance. Returns true if we are at the min or max possible distance.
d | The increment at which we want to adjust the zoom. |
|
protected |
Sets distance based on scroll wheel movement.
|
protectedvirtual |
bool DangerCamera.StartTracking | ( | Transform | target | ) |
Begin tracking to this target. Returns true if tracking was sucessful.
target | Target to track |
void DangerCamera.StartTracking | ( | Vector3 | position | ) |
Track to this position.
position | Position to track to |
void DangerCamera.StartTrackingAndZoom | ( | Transform | target | ) |
Start tracking a target and also zoom towards it.
target | Target to track |
void DangerCamera.StopTracking | ( | ) |
Set the tracking target to backupTarget (meaning we track nothing).
void DangerCamera.TrackAndSnapMouseTo | ( | Vector3 | position | ) |
Track an object. Rotate the camera such that the mouse falls on top of the object.
position | Position to track to and to snap mouse to |
|
protectedvirtual |
Move transform towards trackingTarget.
|
protectedvirtual |
Returns the new direction to move the camera, modified by the camera's orientation and constrained in regards to horizontal movement.
translation | The raw translation input vector. |
|
protectedvirtual |
|
protected |
Wait a bit, and then zoom.
|
protectedvirtual |
Returns the percent of the way between min and max distance from the camera focal point. This is used to modify the translation speed based on zoom level.
|
protectedvirtual |
Set distance given the index of zoomLevels.
bool DangerCamera.allowFraming = true |
Whether this camera will attempt to frame objects.
bool DangerCamera.allowMousePan = true |
Whether this camera listens to mouse pan.
bool DangerCamera.allowRotation = true |
Whether this camera listens to rotational (right click + drag) input.
bool DangerCamera.allowWASDPan = true |
Whether this camera listens for panning (WASD) input.
bool DangerCamera.allowZoom = true |
Whether this camera listens to zooming (scroll wheel) input.
Vector2 DangerCamera.boundsCenter = new Vector2 () |
The center of the bounds.
float DangerCamera.boundsX = 500f |
The x value of the bounds beyond which the camera will not pan.
float DangerCamera.boundsZ = 500f |
The z value of the bounds beyond which the camera will not pan.
|
protected |
The position used to calculate the raycast direction to find the camera's starting focal point.
|
protected |
|
protected |
|
protected |
|
static |
bool DangerCamera.invertRotationX = false |
Whether to invert the x axis.
bool DangerCamera.invertRotationY = false |
Whether to invert the y axis.
KeyCode DangerCamera.KeyZoomIn = KeyCode.LeftBracket |
Key used to zoom in.
KeyCode DangerCamera.KeyZoomOut = KeyCode.RightBracket |
Key used to zoom out.
float DangerCamera.maxDistance = 50 |
Maximum distance from camera to the floor.
float DangerCamera.minDistance = 5 |
Minimal distance from camera to the floor.
float DangerCamera.MouseAngleMaxY = 89.00f * Mathf.Deg2Rad |
The maximum angle of the camera. Clamped to avoid camera inverting.
float DangerCamera.MouseAngleMinY = 23.00f * Mathf.Deg2Rad |
The minimum angle the mouse can bring the camera towards the floor. Lower numbers bring it increasingly parallel to the floor. Clamped to avoid camera inverting.
float DangerCamera.mousePanEdgePercent = 0.05f |
Detect mouse panning when the distance from the mouse to a viewport edge is less than or equal to this. Must be between 0 and 1.
UnityEvent DangerCamera.OnMousePan |
Trigger this event when the mouse pans the camera.
UnityEvent DangerCamera.OnRotate |
Trigger this event when camera rotates.
UnityEvent DangerCamera.OnTrack |
Trigger this event when the camera is tracking.
UnityEvent DangerCamera.OnWASD |
Trigger this event when player uses WASD.
UnityEvent DangerCamera.OnZoom |
Trigger this event when the camera zooms.
float DangerCamera.panSensitivity = 1f |
Adjust how sensitive (fast) panning is (WASD and mouse).
float DangerCamera.rotationLerpSensitivity = 0.5f |
When rotating, how fast the camera will move to follow the mouse. 0 - prevents camera rotation updates 1 - prevents camera rotation smoothing
float DangerCamera.rotationSensitivity = 1f |
Mouse sensitivity when rotating.
float DangerCamera.trackLerpSensitivity = 0.5f |
How fast camera moves when tracking.
float DangerCamera.trackZoomDistance = 6 |
When tracking and zooming, zoom to this distance.
float DangerCamera.zoomLerpSensitivity = 0.5f |
Lerp the distance from the camera to the floor at this rate.
|
protected |
A list of all zoom levels.
|
getprotected |
The camera associated with this DangerCamera object. If DangerCamera.cam is not assigned, this will assign it first.
|
getsetprotected |
Returns the target the camera is currently tracking. Can also set the target. Always set the target here!
|
get |
Returns the speed at which the camera will zoom. The speed is dependent on the distance, and defined in zoomLevels.