Feat/2 weapons foundation #6
@@ -8,6 +8,7 @@ var params: MovementParams:
|
||||
var elapsed: float = 0.0
|
||||
var direction: Vector3 = Vector3.ZERO
|
||||
var _exit_speed: float = 0.0
|
||||
var _last_vel: Vector3 = Vector3.ZERO
|
||||
|
||||
# Cooldown tracked across dash instances
|
||||
static var _last_dash_time: float = -999.0
|
||||
@@ -51,6 +52,7 @@ func enter(_data: Dictionary = {}) -> void:
|
||||
|
||||
machine.player.velocity = direction * _exit_speed
|
||||
machine.on_ground = false
|
||||
_last_vel = machine.player.velocity
|
||||
|
||||
|
||||
func exit() -> void:
|
||||
@@ -70,9 +72,17 @@ func update(delta: float) -> void:
|
||||
return
|
||||
|
||||
# Maintain dash velocity
|
||||
var vel = direction * _exit_speed
|
||||
if machine.player.is_on_floor():
|
||||
var player := machine.player
|
||||
var vel: Vector3 = player.velocity
|
||||
|
||||
if vel.distance_squared_to(_last_vel) > 100.0:
|
||||
machine.switch_to("air")
|
||||
return
|
||||
|
||||
vel = direction * _exit_speed
|
||||
if player.is_on_floor():
|
||||
vel.y = -0.5 # Snap to floor to handle ramps
|
||||
|
||||
machine.player.velocity = vel
|
||||
machine.player.move_and_slide()
|
||||
player.velocity = vel
|
||||
player.move_and_slide()
|
||||
_last_vel = player.velocity
|
||||
|
||||
@@ -8,6 +8,7 @@ var params: MovementParams:
|
||||
var elapsed: float = 0.0
|
||||
var _initial_y_vel: float = 0.0
|
||||
var _run_speed: float = 0.0
|
||||
var _last_vel: Vector3 = Vector3.ZERO
|
||||
|
||||
|
||||
var _current_tangent: Vector3 = Vector3.ZERO
|
||||
@@ -19,6 +20,7 @@ func enter(_data: Dictionary = {}) -> void:
|
||||
# but preserve some if they just jumped onto it.
|
||||
machine.player.velocity.y = minf(machine.player.velocity.y, 1.5)
|
||||
machine.on_ground = false
|
||||
_last_vel = machine.player.velocity
|
||||
|
||||
var hvel := Vector3(machine.player.velocity.x, 0.0, machine.player.velocity.z)
|
||||
_current_tangent = machine.wall_normal.cross(Vector3.UP).normalized()
|
||||
@@ -55,6 +57,12 @@ func update(delta: float) -> void:
|
||||
var player := machine.player
|
||||
var vel: Vector3 = player.velocity
|
||||
|
||||
if vel.distance_squared_to(_last_vel) > 100.0:
|
||||
machine.wall_normal = Vector3.ZERO
|
||||
machine.wall_side = 0.0
|
||||
machine.switch_to("air")
|
||||
return
|
||||
|
||||
# ── Gradual gravity pull (starts light, increases over time) ──────────
|
||||
var gravity_factor := 0.1 + 0.9 * (elapsed / params.wall_run_duration)
|
||||
vel.y -= params.wall_run_gravity * gravity_factor * delta
|
||||
@@ -108,6 +116,7 @@ func update(delta: float) -> void:
|
||||
|
||||
player.velocity = vel
|
||||
player.move_and_slide()
|
||||
_last_vel = player.velocity
|
||||
|
||||
# ── Check still on wall ───────────────────────────────────────────────
|
||||
var still_on_wall := machine.detect_wall_horizontal()
|
||||
|
||||
Reference in New Issue
Block a user