Feat/1 movement foundation #5
@@ -9,6 +9,8 @@ var elapsed: float = 0.0
|
|||||||
var _initial_y_vel: float = 0.0
|
var _initial_y_vel: float = 0.0
|
||||||
|
|
||||||
|
|
||||||
|
var _current_tangent: Vector3 = Vector3.ZERO
|
||||||
|
|
||||||
func enter(_data: Dictionary = {}) -> void:
|
func enter(_data: Dictionary = {}) -> void:
|
||||||
elapsed = 0.0
|
elapsed = 0.0
|
||||||
machine.register_chain_mechanic("wall_run")
|
machine.register_chain_mechanic("wall_run")
|
||||||
@@ -17,6 +19,11 @@ func enter(_data: Dictionary = {}) -> void:
|
|||||||
machine.player.velocity.y = minf(machine.player.velocity.y, 1.5)
|
machine.player.velocity.y = minf(machine.player.velocity.y, 1.5)
|
||||||
machine.on_ground = false
|
machine.on_ground = false
|
||||||
|
|
||||||
|
var hvel := Vector3(machine.player.velocity.x, 0.0, machine.player.velocity.z)
|
||||||
|
_current_tangent = machine.wall_normal.cross(Vector3.UP).normalized()
|
||||||
|
if hvel.dot(_current_tangent) < 0.0:
|
||||||
|
_current_tangent = -_current_tangent
|
||||||
|
|
||||||
# Camera tilt
|
# Camera tilt
|
||||||
var rig = _get_camera_rig()
|
var rig = _get_camera_rig()
|
||||||
if rig:
|
if rig:
|
||||||
@@ -48,10 +55,10 @@ func update(delta: float) -> void:
|
|||||||
|
|
||||||
# ── Move along wall tangent ───────────────────────────────────────────
|
# ── Move along wall tangent ───────────────────────────────────────────
|
||||||
var wall_tangent := machine.wall_normal.cross(Vector3.UP).normalized()
|
var wall_tangent := machine.wall_normal.cross(Vector3.UP).normalized()
|
||||||
# Choose tangent direction based on player's movement direction
|
# Ensure the new tangent aligns with our locked forward direction
|
||||||
var hvel := Vector3(vel.x, 0.0, vel.z)
|
if _current_tangent.dot(wall_tangent) < 0.0:
|
||||||
if hvel.dot(wall_tangent) < 0.0:
|
|
||||||
wall_tangent = -wall_tangent
|
wall_tangent = -wall_tangent
|
||||||
|
_current_tangent = wall_tangent
|
||||||
|
|
||||||
var effective_speed := machine.get_effective_speed(params.wall_run_speed)
|
var effective_speed := machine.get_effective_speed(params.wall_run_speed)
|
||||||
vel.x = wall_tangent.x * effective_speed
|
vel.x = wall_tangent.x * effective_speed
|
||||||
|
|||||||
Reference in New Issue
Block a user