Skip to content

1 How to use the system

ywmaa edited this page Dec 11, 2021 · 6 revisions

GD Script Files

"CharacterMovement_Base.gd" : The Movement System is Written here, so the movement could be used in player or AI by triggering some functions

"PlayerGameplay.gd" : here it calls the functions that causes the player to move as an example for how the system should work

"Camera.gd" : handles the camera movement

"Global.gd" : Has all global variables and enums

"Interaction.gd" : attached to a raycast to do simple interaction system

"Interactable.gd" : a simple script to extend to be able to turn an object into interactable

Main Functions And its uses

"CharacterMovement_Base.gd" main functions :

AddMovementInput(direction: Vector3, Speed: float , Acceleration: float)

it makes the character move and calculates all the stuff like : InputSpeed, InputIsMoving, InputAcceleration, ActualAcceleration, ActualSpeed

jump() obvious, it makes the character jump :)

IKLookAt(position: Vector3) makes the character look at a target

Variables And its uses

Info Variables :

(They are made to get info not change them as they will already change according to the movement)

when a variable starts with the word "Input" it means its value is the amount that the character should move and not the actual value that is based on the real movement and speed, for example the Player Pressed Move Forward but the character is stopped by a wall

the var InputSpeed will = 1.0 while the var ActualSpeed will = 0.0

var ActualAcceleration :Vector3 var InputAcceleration :Vector3

var vertical_velocity := 0.0

var InputSpeed := 0.0 var ActualSpeed := 0.0

var IsMoving := false var InputIsMoving := false

var head_bonked := false

var AimRate_H :float

var CurrentMovementData = {

    Walk_Speed = 1.75,
Run_Speed = 3.75,
Sprint_Speed = 6.5,

Walk_Acceleration = 20.0,
Run_Acceleration = 20.0,
Sprint_Acceleration = 7.5,

idle_Rotation_Rate = 0.5,
Walk_Rotation_Rate = 4.0,
Run_Rotation_Rate = 5.0,
Sprint_Rotation_Rate = 20.0,

}

Movement Variables :

when you change them they update the character status like is it crouching / running , etc most of them are using the @export

@export var IsFlying := false @export var gravity := 9.8

@export var jump_magnitude := 5.0 @export var roll_magnitude := 17.0

var default_height := 2.0 var crouch_height := 1.0

@export var crouch_switch_speed := 5.0

@export var DesiredRotationMode = Global.RotationMode (VelocityDirection , LookingDirection , Aiming)

@export var DesiredGait = Global.Gait (Walking , Running , Sprinting)

@export var DesiredStance = Global.Stance (Standing , Crouching)

@export var DesiredOverlayState = Global.OverlayState (Default , Rifle , Pistol)

The Actual Movement Status :

you could override the "Desired" Variables with these for example you don't want the player to be able to run in specific area

var RotationMode = Global.RotationMode.LookingDirection

var Gait = Global.Gait.Walking

var Stance = Global.Stance.Standing

var OverlayState = Global.OverlayState.Default

Clone this wiki locally