Corgi Engine  v8.8
MoreMountains.CorgiEngine.MultiplayerCameraController Class Reference

Add this script to an orthographic or perspective camera, and it'll try and follow all Character players registered in the LevelManager, and keep them all in the screen. More...

Inheritance diagram for MoreMountains.CorgiEngine.MultiplayerCameraController:
MoreMountains.CorgiEngine.CorgiMonoBehaviour MoreMountains.Tools.MMEventListener< CorgiEngineEvent >

Public Member Functions

virtual void OnMMEvent (CorgiEngineEvent corgiEngineEvent)
 When the player respawns, we reinitialize this object. More...
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< CorgiEngineEvent >
void OnMMEvent (T eventType)
 

Public Attributes

float DampTime = 0.2f
 Defines how fast does the camera change position. Small value : faster camera. More...
 
float OrthoMinSize = 6.5f
 Minimal zoom size. More...
 
float OrthoScreenEdgeBuffer = 4f
 Space around the screen added after the most distant car. More...
 
Vector3 MinPosition
 the minimum coordinates to which the camera will be constrained More...
 
Vector3 MaxPosition
 the maximum coordinates to which the camera will be constrained More...
 

Protected Member Functions

virtual void Initialization ()
 Stores initial position, aspect ratio, field of view, detects targets and level bounds More...
 
virtual void DetectTargets ()
 Looks for and stores the list of players More...
 
virtual void FixedUpdate ()
 At FixedUpdate, we compute the new camera's position More...
 
virtual void CameraMovement ()
 Every fixed update, we determine the new position of the camera and move it More...
 
virtual void MoveCamera ()
 Moves the camera to the newly computed position. More...
 
virtual void CleanPlayersList ()
 Removes disabled players from the list More...
 
virtual void FindAveragePosition ()
 Finds the average position. More...
 
virtual void ComputeZoom ()
 Zooms the camera More...
 
virtual float FindRequiredOrthographicSize ()
 Finds the required size of the orthographic camera's zoom. More...
 
virtual float FindRequiredDistance ()
 Determines the perspective camera's z position More...
 
virtual void GetLevelBounds ()
 Gets the levelbounds coordinates to lock the camera into the level More...
 
virtual void ClampNewPosition ()
 Keeps the camera within the defined bounds More...
 
virtual void OnEnable ()
 On enable, we start listening to events More...
 
virtual void OnDisable ()
 On disable, we stop listening to events More...
 

Protected Attributes

Camera _camera
 
float _zoomSpeed
 
Vector3 _moveVelocity
 
Vector3 _newPosition
 
Vector3 _averagePosition
 
float _initialZ
 
Bounds _levelBounds
 
float _xMin
 
float _xMax
 
float _yMin
 
float _yMax
 
float _aspectRatio
 
float _tanFov
 

Properties

List< Transform > Players [get, set]
 the list of players More...
 

Detailed Description

Add this script to an orthographic or perspective camera, and it'll try and follow all Character players registered in the LevelManager, and keep them all in the screen.

Member Function Documentation

◆ CameraMovement()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.CameraMovement ( )
protectedvirtual

Every fixed update, we determine the new position of the camera and move it

◆ ClampNewPosition()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.ClampNewPosition ( )
protectedvirtual

Keeps the camera within the defined bounds

◆ CleanPlayersList()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.CleanPlayersList ( )
protectedvirtual

Removes disabled players from the list

◆ ComputeZoom()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.ComputeZoom ( )
protectedvirtual

Zooms the camera

◆ DetectTargets()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.DetectTargets ( )
protectedvirtual

Looks for and stores the list of players

◆ FindAveragePosition()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.FindAveragePosition ( )
protectedvirtual

Finds the average position.

◆ FindRequiredDistance()

virtual float MoreMountains.CorgiEngine.MultiplayerCameraController.FindRequiredDistance ( )
protectedvirtual

Determines the perspective camera's z position

Returns
The required distance.

◆ FindRequiredOrthographicSize()

virtual float MoreMountains.CorgiEngine.MultiplayerCameraController.FindRequiredOrthographicSize ( )
protectedvirtual

Finds the required size of the orthographic camera's zoom.

Returns
The required size.

◆ FixedUpdate()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.FixedUpdate ( )
protectedvirtual

At FixedUpdate, we compute the new camera's position

◆ GetLevelBounds()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.GetLevelBounds ( )
protectedvirtual

Gets the levelbounds coordinates to lock the camera into the level

◆ Initialization()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.Initialization ( )
protectedvirtual

Stores initial position, aspect ratio, field of view, detects targets and level bounds

◆ MoveCamera()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.MoveCamera ( )
protectedvirtual

Moves the camera to the newly computed position.

◆ OnDisable()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.OnDisable ( )
protectedvirtual

On disable, we stop listening to events

◆ OnEnable()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.OnEnable ( )
protectedvirtual

On enable, we start listening to events

◆ OnMMEvent()

virtual void MoreMountains.CorgiEngine.MultiplayerCameraController.OnMMEvent ( CorgiEngineEvent  corgiEngineEvent)
virtual

When the player respawns, we reinitialize this object.

Parameters
checkpointCheckpoint.
playerPlayer.

Member Data Documentation

◆ _aspectRatio

float MoreMountains.CorgiEngine.MultiplayerCameraController._aspectRatio
protected

◆ _averagePosition

Vector3 MoreMountains.CorgiEngine.MultiplayerCameraController._averagePosition
protected

◆ _camera

Camera MoreMountains.CorgiEngine.MultiplayerCameraController._camera
protected

◆ _initialZ

float MoreMountains.CorgiEngine.MultiplayerCameraController._initialZ
protected

◆ _levelBounds

Bounds MoreMountains.CorgiEngine.MultiplayerCameraController._levelBounds
protected

◆ _moveVelocity

Vector3 MoreMountains.CorgiEngine.MultiplayerCameraController._moveVelocity
protected

◆ _newPosition

Vector3 MoreMountains.CorgiEngine.MultiplayerCameraController._newPosition
protected

◆ _tanFov

float MoreMountains.CorgiEngine.MultiplayerCameraController._tanFov
protected

◆ _xMax

float MoreMountains.CorgiEngine.MultiplayerCameraController._xMax
protected

◆ _xMin

float MoreMountains.CorgiEngine.MultiplayerCameraController._xMin
protected

◆ _yMax

float MoreMountains.CorgiEngine.MultiplayerCameraController._yMax
protected

◆ _yMin

float MoreMountains.CorgiEngine.MultiplayerCameraController._yMin
protected

◆ _zoomSpeed

float MoreMountains.CorgiEngine.MultiplayerCameraController._zoomSpeed
protected

◆ DampTime

float MoreMountains.CorgiEngine.MultiplayerCameraController.DampTime = 0.2f

Defines how fast does the camera change position. Small value : faster camera.

◆ MaxPosition

Vector3 MoreMountains.CorgiEngine.MultiplayerCameraController.MaxPosition

the maximum coordinates to which the camera will be constrained

◆ MinPosition

Vector3 MoreMountains.CorgiEngine.MultiplayerCameraController.MinPosition

the minimum coordinates to which the camera will be constrained

◆ OrthoMinSize

float MoreMountains.CorgiEngine.MultiplayerCameraController.OrthoMinSize = 6.5f

Minimal zoom size.

◆ OrthoScreenEdgeBuffer

float MoreMountains.CorgiEngine.MultiplayerCameraController.OrthoScreenEdgeBuffer = 4f

Space around the screen added after the most distant car.

Property Documentation

◆ Players

List<Transform> MoreMountains.CorgiEngine.MultiplayerCameraController.Players
getset

the list of players


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