MikeCL
Here's my code as it relates to movement:
@export var acceleration = 2.5 # higher starts quicker
@export var deceleration_bounce = 9.5 # higher stops quicker
@export var deceleration_blast = 9.5 # higher stops quicker
@export var deceleration_spin = 3.5 # higher stops quicker
@export var direction_last = Vector2(1, 1) # default direction facing (SE)
@export var speed_move = 55 # speed when moving with input
@export var speed_spin = 100 # speed when spinning
@export var speed_max = 999 # maximum speed
@export var bounce_strength = 200 # strength of bounce
@export var blast_pwr_lvl_min = 300 # for BLAST
@export var blast_pwr_lvl_max = 700 # for BLAST
@export var blast_pwr_lvl_increment = 100 # for BLAST
func _physics_process(delta: float): # delta variable has value of the frame time that engine passes to function.
# local variables
var collision = move_and_collide(velocity * delta) # define collision (add true to affect only collision and not movement)
var direction_input = Input.get_vector("left", "right", "up", "down")
var direction_facing = direction_last # last direction is direction you are facing
direction_last = get_direction() # returns value from respective function
States.MOVE:
if collision and collision.get_collider().is_in_group("bumper_group"):
state = States.BOUNCE
elif Input.is_action_just_released("move"):
state = States.IDLE # change state
elif Input.is_action_pressed("space_bar") and can_charge_player:
state = States.CHARGE # change state
else: # run move code
speed = speed_move # set speed to move speed
velocity = direction_input * speed # move