Jumpvalley 0.5.0
An app and library that can be used to test and run 3D platformer levels. Currently being made with Godot.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Properties | Events | List of all members
Jumpvalley.Players.Movement.BaseMover Class Reference

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...

Inheritance diagram for Jumpvalley.Players.Movement.BaseMover:

Public Types

enum  BodyState {
  Stopped = 0 , Moving = 1 , Running = 2 , Rising = 3 ,
  Jumping = 4 , Climbing = 5 , Falling = 6
}
 The current movement state of the character associated with the mover. More...
 

Public Member Functions

 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)
 

Public Attributes

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 Public Attributes

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.
 

Protected Member Functions

void RaiseBodyStateChangedEvent (BodyState oldState, BodyState newState)
 
void RaiseOnFastTurnToggled (bool fastTurnEnabled)
 

Properties

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.
 

Events

EventHandler< BodyStateChangedArgsBodyStateChanged
 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.
 

Detailed Description

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.

Member Enumeration Documentation

◆ 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.

Member Function Documentation

◆ Dispose()

new void Jumpvalley.Players.Movement.BaseMover.Dispose ( )
inline

Callback to associate with the normal process step in the current scene tree.

Parameters
delta

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
yawThe 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
deltaThe time it took to complete the physics frame in seconds
yawThe 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
deltaThe 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: