From 942ab25abf8054986f643caa812d4304786fcfa6 Mon Sep 17 00:00:00 2001 From: derek Date: Mon, 16 Jun 2025 15:10:44 -0500 Subject: [PATCH] more work on wall running --- assets/player.tscn | 3 ++- project.godot | 2 +- scripts/PlayerStates.gd | 7 ++++--- scripts/player_wall_running.gd | 17 +++++++++++++---- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/assets/player.tscn b/assets/player.tscn index 95817db..28414c2 100644 --- a/assets/player.tscn +++ b/assets/player.tscn @@ -158,7 +158,8 @@ script = ExtResource("5_m0ick") [node name="Wall Running" type="Node" parent="States"] script = ExtResource("6_1npgd") -move_speed = 20.0 +move_speed = 15.0 +move_transition_speed = 15.0 [node name="Ground Pound" type="Node" parent="States"] diff --git a/project.godot b/project.godot index 308b7ed..0f0d656 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="First Person Test" config/tags=PackedStringArray("fps") -run/main_scene="uid://b55ukxds1s7ih" +run/main_scene="uid://dsw00ml8rv6xo" config/features=PackedStringArray("4.4", "Forward Plus") config/icon="uid://6svuq1l83al5" diff --git a/scripts/PlayerStates.gd b/scripts/PlayerStates.gd index ba26422..97671ab 100644 --- a/scripts/PlayerStates.gd +++ b/scripts/PlayerStates.gd @@ -43,6 +43,7 @@ func start_wall_running(): print("SURFACE NORMAL : ", running_surface_normal) - character.wall_run_direction = wall_run_direction - character.wall_run_surface_normal = running_surface_normal - Transitioned.emit(self,"wall running") + if running_surface_normal: + character.wall_run_direction = wall_run_direction + character.wall_run_surface_normal = running_surface_normal + Transitioned.emit(self,"wall running") diff --git a/scripts/player_wall_running.gd b/scripts/player_wall_running.gd index f70ed1f..9fb1ced 100644 --- a/scripts/player_wall_running.gd +++ b/scripts/player_wall_running.gd @@ -7,15 +7,24 @@ func Physics_Update(delta): else: wall_run_movement(delta) - apply_gravity(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_surface_normal).normalized() * 10 + 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 * 7) - character.velocity.z = lerp(character.velocity.z,character.wall_run_direction.z * move_speed,delta * 7) + 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