viewers access
public class Player.PlayerController
CyberPsychosis > Player > PlayerController
The main wrapper that connects all different player elements through player inputs
Player Controller handles all potential input cases, and switches the state machines accordingly. 99% of actual behaviour is controlled by these state machines rather than the player controller itself. aside from that events are being handled by the PlayerManager.
| Type | Name | Description |
|---|---|---|
void |
SetEulerAngles(Vector3) | Sets the players euler angles |
void |
SetPosition(Vector3) | Sets the players position |
void |
SetCameraRotation(Vector3) | Sets the rotation of the cameraRig and cameraPitch objects |
void |
RotateCamera(Vector3) | Additional euler rotation to the cameraRig and cameraPitch objects |
void |
GrabWeapon(Weapon) | Switches to input weapon |
void |
ResetMovementState() | Resets the movement state to either defaultMovementState or AirMovementState based on wether the player is grounded or not |
Vector2 |
GetMovementInput() | Returns the normalized WASD input in a vector 2 |
Vector3 |
ToRelativeMovement(Vector2) | Turns 2D input movement into camera based 3D directions |
void |
ReleaseAirControl() | Sets the air control to 0, before it will work its way back to its default value |
void |
AddFriction(float) | Slows down the player by the input factor |
void |
SetHeight(float) | Sets the target height of the player, it will lerp to that height |
void |
ResetHeight() | Resets the target height of the player to the baseHeight |
| Type | Name | Description |
|---|---|---|
CharacterController |
character | The unity CharacterConteroller, responsible for collision detection |
Transform |
CameraRig | The part of the camera rig responsible for Y axis rotation |
Transform |
CameraPitch | The part of the camera rig responsible for X axis rotation |
Camera |
cameraObject | The camera itself |
Transform |
ItemRoot | Parent object for all inhand items |
Vector3 |
velocity | The current player velocity |
float |
baseHeight | The base height of the player, the target height will return to this value when resetting the height, constant |
float |
currentAirControl | The current amount of air control, can change based on actions |
float |
currentHeight | The current height of the character controller |
float |
targetHeight | The destined height of the character controller |
float |
lastGrounded | Time in seconds from the last time it was grounded |
bool |
isGrounded | Returns true if the character was grounded within the last 100 miliseconds |
float |
distanceToGround | The closest distance to the ground in standard units |
float |
distanceToRoof | The closest distance to the roof in standard units |
Vector3 |
groundNormal | The normal of the ground currently close below the player |
Vector3 |
CameraForward | The camera's forward vector |
float |
dashCooldown | Cooldown in seconds before player can use dash again |
StateMachine |
movementMachine | The state machine controlling the active movement behaviour like dashing, sliding or just default movement |
StateMachine |
lookMachine | The state machine controlling the active look behaviour, can be changed to include scripted camera's or immovable camera behaviour |
StateMachine |
jumpMachine | The state machine controlling the active jump behaviour like normal jumping, wall jumping and double jumping |