Files
fps_project_1/scripts/player_wall_running.gd
2025-06-16 15:10:44 -05:00

31 lines
897 B
GDScript

extends PlayerState
class_name PlayerWallRunning
func Physics_Update(delta):
if character.is_on_floor():
Transitioned.emit(self,"on foot")
else:
wall_run_movement(delta)
if Input.is_action_just_pressed("jump"):
wall_jump()
enable_wall_rays()
if !can_wall_run():
Transitioned.emit(self,"in air")
func wall_jump():
character.velocity += (Vector3(0,1,0) + character.wall_run_direction).normalized() * 15
Transitioned.emit(self,"in air")
func wall_run_movement(delta):
if Input.is_action_pressed("move_up"):
character.velocity.x = lerp(character.velocity.x,character.wall_run_direction.x * move_speed,delta * move_transition_speed)
character.velocity.z = lerp(character.velocity.z,character.wall_run_direction.z * move_speed,delta * move_transition_speed)
else:
Transitioned.emit(self,"in air")
func wall_run_gravity(delta):
character.velocity.y -= 9.8 * .75 * delta