FirstPersonMovement
namespace Griff.Modules.FirstPerson;
public sealed class FirstPersonMovement : ComponentFirst-person controls with no code: W and S (or up and down) walk, A and D strafe, the left and right arrows turn, and the mouse looks around once the game is clicked (Esc gives the mouse back). Holding Dash (Left Shift) runs. On a controller the left stick walks and strafes and the right stick turns. It turns the entity’s Rotation Z, the way a FirstPersonView looks. Needs a Body and a collider (a circle slides along walls best).
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”Acceleration
Section titled “Acceleration”public float Acceleration { get; set; }How quickly it gets up to speed and stops, in units per second per second. 0 is at once.
Controllable
Section titled “Controllable”public bool Controllable { get; set; }Untick it (from a script, in a cutscene) to ignore the player’s input. Its Focus action ticks it and unticks it on everything else the player plays (a board, another character), and back.
Facing
Section titled “Facing”public Vector2 Facing { get; }The way it’s facing across the floor, as a unit vector.
LookUpDown
Section titled “LookUpDown”public bool LookUpDown { get; set; }Let the mouse (and the right stick) look up and down a little, as well as turn.
MouseLook
Section titled “MouseLook”public bool MouseLook { get; set; }Turn with the mouse. The game takes the mouse when it’s clicked, and gives it back with Esc.
MouseSensitivity
Section titled “MouseSensitivity”public float MouseSensitivity { get; set; }Degrees turned for each pixel the mouse moves.
public float Pitch { get; set; }Degrees it’s looking up (positive) or down (negative), with LookUpDown.
RunSpeed
Section titled “RunSpeed”public float RunSpeed { get; set; }Speed while Dash is held. The same as Speed for no running.
public float Speed { get; set; }Walking speed, in world units per second.
StepLength
Section titled “StepLength”public float StepLength { get; set; }World units between footsteps.
StepSound
Section titled “StepSound”public string? StepSound { get; set; }A footstep sound, played every StepLength units walked.
Stride
Section titled “Stride”public float Stride { get; }How fast it’s walking, from 0 (standing) to 1 (full speed): for the view’s bob.
TurnSpeed
Section titled “TurnSpeed”public float TurnSpeed { get; set; }Degrees per second the arrow keys (and the right stick, all the way over) turn it.