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

Public Member Functions

new void ResetTarget ()
 
void _UpdateFPCamera ()
 
float GetHeadBobSpeed ()
 Gets the desired head-bobbing speed, to be manipulated via a custom script if headBobMethod = FirstPersonHeadBobMethod.CustomScript. More...
 
void SetPitch (float angle, bool isInstant=true)
 Sets the pitch to a specific angle. More...
 
void IncreasePitch (float increase)
 Increases the pitch, accounting for sensitivity More...
 
bool IsTilting ()
 
float GetTilt ()
 
float GetTargetTilt ()
 
- Public Member Functions inherited from AC._Camera
virtual Vector2 CreateRotationOffset ()
 Returns a vector by which to tweak the camera's rotation. The x-axis will control the spin, and the y-axis will control the pitch. More...
 
virtual void SwitchTarget (Transform _target)
 Switches the camera's target. More...
 
virtual bool Is2D ()
 Checks if the camera is for 2D games. This is necessary for working out if the MainCamera needs to change its projection matrix. More...
 
virtual void _Update ()
 
virtual void MoveCameraInstant ()
 
void SetSplitScreen ()
 
void RemoveSplitScreen ()
 
virtual Vector2 GetPerspectiveOffset ()
 Gets the actual horizontal and vertical panning offsets. More...
 
bool IsActive ()
 Checks if the Camera is currently the MainCamera's active camera (attachedCamera) More...
 
void MakeActive ()
 

Public Attributes

Vector2 sensitivity = new Vector2 (15f, 15f)
 
float minY = -60f
 
float maxY = 60f
 
bool allowMouseWheelZooming = false
 
float minimumZoom = 13f
 
float maximumZoom = 65f
 
bool headBob = true
 
FirstPersonHeadBobMethod headBobMethod = FirstPersonHeadBobMethod.BuiltIn
 
float builtInSpeedFactor = 1f
 
float bobbingAmount = 0.2f
 
string headBobSpeedParameter
 
string headBobSpeedSideParameter
 
float headBobLerpSpeed = 5f
 
- Public Attributes inherited from AC._Camera
bool targetIsPlayer = true
 
Transform target
 
bool isDragControlled = false
 
float focalDistance = 10f
 

Protected Member Functions

override void Awake ()
 
override void OnEnable ()
 
override void OnDisable ()
 
void ApplyTilt ()
 
- Protected Member Functions inherited from AC._Camera
virtual void Start ()
 
Vector3 PositionRelativeToCamera (Vector3 _position)
 
Vector3 RightVector ()
 
Vector3 ForwardVector ()
 
float ConstrainAxis (float desired, Vector2 range, bool isAngle=false)
 

Protected Attributes

float actualTilt = 0f
 
float bobTimer = 0f
 
float height = 0f
 
float deltaHeight = 0f
 
Player player
 
LerpUtils.FloatLerp tiltLerp = new LerpUtils.FloatLerp ()
 
float targetTilt
 
- Protected Attributes inherited from AC._Camera
Char targetChar
 
Camera _camera
 
Vector2 inputMovement
 
bool is2D = false
 

Additional Inherited Members

- Properties inherited from AC._Camera
Transform Target [get]
 
Transform CameraTransform [get]
 
Transform Transform [get]
 
Camera Camera [get]
 
bool isFor2D [get, set]
 
virtual TransparencySortMode TransparencySortMode [get]
 
Vector3 TargetForward [get]
 
virtual bool CursorOffsetForcesTranslation [get]
 

Detailed Description

A camera used for first-person games. To use it, attach it to a child object of your Player prefab, as well as a Camera. It will then be used during gameplay if SettingsManager's movementMethod = MovementMethod.FirstPerson. This script only affects the pitch rotation - yaw rotation occurs by rotating the base object. Headbobbing code adapted from Mr. Animator's code: http://wiki.unity3d.com/index.php/Headbobber

Member Function Documentation

◆ _UpdateFPCamera()

void AC.FirstPersonCamera._UpdateFPCamera ( )

Updates the camera's transform. This is called every frame by StateHandler.

◆ GetHeadBobSpeed()

float AC.FirstPersonCamera.GetHeadBobSpeed ( )

Gets the desired head-bobbing speed, to be manipulated via a custom script if headBobMethod = FirstPersonHeadBobMethod.CustomScript.

Returns
The desired head-bobbing speed. Returns zero if the player is idle.

◆ GetTargetTilt()

float AC.FirstPersonCamera.GetTargetTilt ( )

Gets the intended angle by which the camera wants to look up or down, with negative values looking upward.

◆ GetTilt()

float AC.FirstPersonCamera.GetTilt ( )

Gets the angle by which the camera is looking up or down, with negative values looking upward.

◆ IncreasePitch()

void AC.FirstPersonCamera.IncreasePitch ( float  increase)

Increases the pitch, accounting for sensitivity

Parameters
increaseThe amount to increase sensitivity by

◆ IsTilting()

bool AC.FirstPersonCamera.IsTilting ( )

Checks if the camera is looking up or down.

◆ ResetTarget()

new void AC.FirstPersonCamera.ResetTarget ( )
virtual

Overrides the default in _Camera to do nothing.

Reimplemented from AC._Camera.

◆ SetPitch()

void AC.FirstPersonCamera.SetPitch ( float  angle,
bool  isInstant = true 
)

Sets the pitch to a specific angle.

Parameters
angleThe new pitch angle

If True, then the pitch will be set instantly. Otherwise, it will move over time according to the Player's turnSpeed

Member Data Documentation

◆ allowMouseWheelZooming

bool AC.FirstPersonCamera.allowMouseWheelZooming = false

If True, the mousewheel can be used to zoom the camera's FOV

◆ bobbingAmount

float AC.FirstPersonCamera.bobbingAmount = 0.2f

The bobbing magnitude, if headBob = True and headBobMethod = FirstPersonHeadBobMethod.BuiltIn

◆ builtInSpeedFactor

float AC.FirstPersonCamera.builtInSpeedFactor = 1f

The bobbing speed, if headBob = True and headBobMethod = FirstPersonHeadBobMethod.BuiltIn

◆ headBob

bool AC.FirstPersonCamera.headBob = true

If True, then the camera will bob up and down as the Player moves

◆ headBobLerpSpeed

float AC.FirstPersonCamera.headBobLerpSpeed = 5f

Smoothing factor for parameter values when headBobMethod = FirstPersonHeadBobMethod.CustomAnimation

◆ headBobMethod

FirstPersonHeadBobMethod AC.FirstPersonCamera.headBobMethod = FirstPersonHeadBobMethod.BuiltIn

The method of head-bobbing to employ, if headBob = True (BuiltIn, CustomAnimation, CustomScript)

◆ headBobSpeedParameter

string AC.FirstPersonCamera.headBobSpeedParameter

The name of the float parameter in headBobAnimator to set as the forward head-bob speed, if headBob = True and headBobMethod = FirstPersonHeadBobMethod.CustomAnimation

◆ headBobSpeedSideParameter

string AC.FirstPersonCamera.headBobSpeedSideParameter

The name of the float parameter in headBobAnimator to set as the side head-bob speed, if headBob = True and headBobMethod = FirstPersonHeadBobMethod.CustomAnimation

◆ maximumZoom

float AC.FirstPersonCamera.maximumZoom = 65f

The maximum FOV, if allowMouseWheelZooming = True

◆ maxY

float AC.FirstPersonCamera.maxY = 60f

The maximum pitch angle

◆ minimumZoom

float AC.FirstPersonCamera.minimumZoom = 13f

The minimum FOV, if allowMouseWheelZooming = True

◆ minY

float AC.FirstPersonCamera.minY = -60f

The minimum pitch angle

◆ sensitivity

Vector2 AC.FirstPersonCamera.sensitivity = new Vector2 (15f, 15f)

The sensitivity of free-aiming