Skip to content
André edited this page Jul 13, 2022 · 1 revision

The Player class contains all the logic and mechanics for the player.

Functionality

Player.cs

Player.cs is the main script for the player. It contains all the logic for the states the player is in. By doing so, we can have a firm grip on how the player does stuff like its movement, aiming, HUD (Head-Up Display), etc. All the other behaviours are self-contained in their script through partial classes. (Examples: Player.Movement.cs, Player.Aiming.cs, Player.Inventory.cs)

Movement Mechanics

The player movement mechanics are contained inside the scripts Player.Movement.cs and Player.GrapplingHook.cs. By being inside these two, it's easier to maintain which state it's currently in, be it "On Air", "On Ground", "Dashing", "Tethering", "On Parachute", etc.

Animations

The animations are contained in the Player.Animator.cs and PlayerAnimationEvents.cs. The first script is responsible for containing all the logic and functionality for the animations to play and the Networking aspect of it, sending the information to the other players about how the local player is animated. The second script is a helper script that allows us to add extra functionality to the animations themselves, like adding shake to the camera, communicating with different objects, and allowing us to have more precise control over how the overall aspect of the game works out.

User Interface (UI)

The player also contains dozens of scripts regarding UI. Each one is responsible for a single part of the UI and its functionality. You can easily understand which script is for since its naming convention is basically Player.UI.NameOfTheUIPart. (Examples: Player.UI.Chat, Player.UI.Oven, Player.UI.HUD)

Inventory

Talking more specifically about the inventory in regards to UI, it's the most sophisticated script as it's responsible for the most important aspect of the game loop, which is the management of the items.

Extra

There are a lot more scripts comprised in the Player ramification of scripts that contain specific mechanics or logic, like Player.Fishing.cs, Player.Spawn.cs, Player.Sounds.cs, etc. You can easily understand them as they were built with that in mind.

Clone this wiki locally