This is the base class that provides a player's character the ability to move in different directions, jump, and climb. It serves mainly as a controller interface for developers to build on.
The design of this takes lots of inspiration from Roblox's PlayerModule.
More...
|
| BaseMover () |
| Constructs a new instance of BaseMover that can be used to handle character movement.
|
|
bool | IsOnFloor () |
| Returns whether or not the associated CharacterBody3D is on the floor.
|
|
Vector3 | GetMoveVector (float yaw) |
| Calculates and returns the move vector that the player wants to move the character in, regardless of whether or not they're currently jumping or climbing.
The calculated move vector can be rotated to a specified yaw angle. This is useful when you want to make the character move in the direction that the camera is facing.
|
|
bool | IsTryingToMove () |
| Returns whether or not the character is trying to move.
The character is considered to want to move when either ForwardValue or RightValue isn't zero.
|
|
Vector3 | GetMoveVelocity (float delta, float yaw) |
| Gets the velocity that the character wants to move at for the current physics frame.
|
|
void | HandlePhysicsStep (double delta) |
| Callback to associate with the physics process step in the current scene tree.
|
|
new void | Dispose () |
| Callback to associate with the normal process step in the current scene tree.
|
|
override void | _PhysicsProcess (double delta) |
|
|
float | ForwardValue = 0 |
| Scalar in which the character wishes to go forward in the range of [-1, 1].
A value less than 0 indicates that the character wants to go backwards while a value greater than 0 indicates that the character wants to go forwards.
|
|
float | RightValue = 0 |
| Scalar in which the character wishes to go right in the range of [-1, 1].
A value less than 0 indicates that the character wants to go left while a value greater than 0 indicates that the character wants to go right.
|
|
float | Gravity = 9.8f |
| The gravity that the character experiences in meters per second squared.
|
|
float | JumpVelocity = 5f |
| The initial Y-velocity of the character's jump.
|
|
float | Acceleration = 16f |
| The acceleration that the character's XZ velocity increases at while the character is trying to move on the ground.
This doesn't affect upward and downward movement, and therefore, this only affects X and Z movement.
|
|
float | AirAcceleration = 8f |
| The acceleration that the character's XZ velocity increases at while in the air.
|
|
float | Deceleration = 16f |
| The deceleration that the character's XZ velocity decreases at when on the ground and one of these other conditions is true:
-
The character is trying to stop
-
The character has exceeded max speed
|
|
float | AirDeceleration = 8f |
| The deceleration that the character's XZ velocity decreases at when in the air and one of these other conditions is true:
-
The character is trying to stop
-
The character has exceeded max speed
|
|
float | CameraYaw = 0 |
| The current yaw angle of the camera that's currently associated with the character.
|
|
bool | IsClimbing = false |
| Whether or not the player is currently climbing.
|
|
bool | IsJumping = false |
| Whether or not the player is currently jumping.
|
|
BaseCamera | Camera = null |
| The BaseCamera to bind CameraYaw to.
|
|
|
static readonly string | CHARACTER_ROOT_COLLIDER_NAME = "RootCollider" |
| The name of the CollisionShape3D that should be primarily in charge of handling a character's collision.
|
|
|
void | RaiseBodyStateChangedEvent (BodyState oldState, BodyState newState) |
|
void | RaiseOnFastTurnToggled (bool fastTurnEnabled) |
|
|
BodyState | CurrentBodyState [get, set] |
| The current movement state of the character that's being moved by this BaseMover
|
|
float | Speed [get, set] |
| How fast the character can move in meters per second.
|
|
bool | IsFastTurnEnabled [get, set] |
| If the value of this property is true, the character's yaw angle will instantly be set to a specified "destination" yaw (for example, the current yaw of a BaseCamera). Otherwise, while the character is moving, the character's yaw will gradually approach the destination yaw until the character's yaw and the destination yaw match.
|
|
bool | IsRunning [get, set] |
| Whether or not the BaseMover is actively updating every physics and process frame.
|
|
CharacterBody3D | Body [get, set] |
| The CharacterBody3D that this BaseMover is binded to.
|
|
BodyRotator | Rotator [get] |
| The BodyRotator that will be rotating Body
|
|
Climber | CurrentClimber [get] |
| The Climber that's currently in charge of determining whether or not the character can climb at the current physics frame.
|
|
Vector3 | LastVelocity [get] |
| The most recent character velocity. In BaseMover's PhysicsProcess updater, this is read by GetMoveVelocity to determine what the velocity in the previous physics frame was before this value gets updated again.
|
|
|
EventHandler< BodyStateChangedArgs > | BodyStateChanged |
| Event that's raised when the character being moved by this BaseMover changes.
|
|
EventHandler< bool > | OnFastTurnToggled |
| Event that's raised when the value of IsFastTurnEnabled changes. The boolean event argument is the new value of IsFastTurnEnabled.
|
|
This is the base class that provides a player's character the ability to move in different directions, jump, and climb. It serves mainly as a controller interface for developers to build on.
The design of this takes lots of inspiration from Roblox's PlayerModule.
◆ BodyState
The current movement state of the character associated with the mover.
Enumerator |
---|
Stopped | The character is not moving.
|
Moving | The character is moving, but not at the user's request.
|
Running | The character is walking/running at the user's request.
|
Rising | The character is moving upward, but not at the user's request (e.g. the character is moving upward while IsJumping and IsClimbing are both false)
|
Jumping | The character is jumping. A character is jumping only while IsJumping is set to true and the character is moving upward.
|
Climbing | The character is climbing something.
|
Falling | The character is falling down.
|
◆ Dispose()
new void Jumpvalley.Players.Movement.BaseMover.Dispose |
( |
| ) |
|
|
inline |
Callback to associate with the normal process step in the current scene tree.
- Parameters
-
Disposes of this BaseMover
◆ GetMoveVector()
Vector3 Jumpvalley.Players.Movement.BaseMover.GetMoveVector |
( |
float | yaw | ) |
|
|
inline |
Calculates and returns the move vector that the player wants to move the character in, regardless of whether or not they're currently jumping or climbing.
The calculated move vector can be rotated to a specified yaw angle. This is useful when you want to make the character move in the direction that the camera is facing.
- Parameters
-
yaw | The yaw angle that the forward and right values are relative to. |
- Returns
- The calculated move vector
◆ GetMoveVelocity()
Vector3 Jumpvalley.Players.Movement.BaseMover.GetMoveVelocity |
( |
float | delta, |
|
|
float | yaw ) |
|
inline |
Gets the velocity that the character wants to move at for the current physics frame.
- Parameters
-
delta | The time it took to complete the physics frame in seconds |
yaw | The yaw angle to make the move vector relative to. |
- Returns
◆ HandlePhysicsStep()
void Jumpvalley.Players.Movement.BaseMover.HandlePhysicsStep |
( |
double | delta | ) |
|
|
inline |
Callback to associate with the physics process step in the current scene tree.
- Parameters
-
delta | The time it took and should take to complete the physics frame in seconds |
◆ IsOnFloor()
bool Jumpvalley.Players.Movement.BaseMover.IsOnFloor |
( |
| ) |
|
|
inline |
Returns whether or not the associated CharacterBody3D is on the floor.
- Returns
◆ IsTryingToMove()
bool Jumpvalley.Players.Movement.BaseMover.IsTryingToMove |
( |
| ) |
|
|
inline |
Returns whether or not the character is trying to move.
The character is considered to want to move when either ForwardValue or RightValue isn't zero.
- Returns
- Whether or not the character is trying to move.
The documentation for this class was generated from the following file: