Feat/1 movement foundation #5

Merged
Dotts merged 40 commits from feat/1-movement-foundation into main 2026-06-03 21:34:25 -07:00
4 changed files with 17 additions and 17 deletions
Showing only changes of commit 6cac1f4032 - Show all commits
+2 -2
View File
@@ -18,10 +18,10 @@ func enter(_data: Dictionary = {}) -> void:
if wish_dir.length_squared() > 0.0: if wish_dir.length_squared() > 0.0:
direction = wish_dir.normalized() direction = wish_dir.normalized()
else: else:
direction = -machine.player.global_transform.basis.z.normalized() direction = -machine.player.global_transform.basis.z
direction.y = 0.0 direction.y = 0.0
direction = direction.normalized() direction = direction.normalized()
direction = (machine.player.global_transform.basis * Vector4(direction.x, 0.0, direction.y, 0.0)).normalized() direction = (machine.player.global_transform.basis * Vector3(direction.x, 0.0, direction.y)).normalized()
machine.register_chain_mechanic("dash") machine.register_chain_mechanic("dash")
machine.player.velocity = direction * machine.get_effective_speed(params.dash_speed) machine.player.velocity = direction * machine.get_effective_speed(params.dash_speed)
machine.on_ground = false machine.on_ground = false
+4 -3
View File
@@ -98,12 +98,13 @@ func detect_wall() -> Vector3:
hvel = Vector3.FORWARD hvel = Vector3.FORWARD
var space_state := machine.player.get_world_3d().direct_space_state var space_state := machine.player.get_world_3d().direct_space_state
for offset_sign in [1.0, -1.0]: for offset_sign in [1.0, -1.0]:
var offset := hvel.cross(Vector3.UP) * offset_sign * machine.player.shape_owner_get_owner(0).shape_get_radius() if false else hvel.cross(Vector3.UP) * offset_sign * 0.4 var dir: Vector3 = (hvel.cross(Vector3.UP) * offset_sign).normalized()
var ray := PhysicsRayQueryParameters3D.create(origin + offset + Vector3.UP * params.wall_ray_up_height, origin + offset + Vector3.DOWN * params.wall_ray_down_height) var offset: Vector3 = dir * 0.4
var ray := PhysicsRayQueryParameters3D.create(origin + offset + Vector3.UP * params.wall_ray_up_height, origin + offset - Vector3.DOWN * params.wall_ray_down_height)
ray.exclude = [machine.player.get_rid()] ray.exclude = [machine.player.get_rid()]
var hit := space_state.intersect_ray(ray) var hit := space_state.intersect_ray(ray)
if not hit.is_empty(): if not hit.is_empty():
var n := hit.get("normal", Vector3.ZERO) var n: Vector3 = hit.get("normal", Vector3.ZERO)
if n.y < 0.3 and n.length_squared() > 0.0: if n.y < 0.3 and n.length_squared() > 0.0:
return n.normalized() return n.normalized()
return Vector3.ZERO return Vector3.ZERO
+10 -10
View File
@@ -13,7 +13,7 @@ func enter(_data: Dictionary = {}) -> void:
machine.register_chain_mechanic("slide") machine.register_chain_mechanic("slide")
# Lower player capsule # Lower player capsule
var player_node = machine.player var player_node = machine.player
var shape: CapsuleShape3D = player_node.shape_owner_get_shape(0) var shape: CapsuleShape3D = machine.player.shape_owner_get_shape(0, 0)
if shape: if shape:
shape.height = shape.height * 0.5 shape.height = shape.height * 0.5
@@ -39,22 +39,22 @@ func update(delta: float) -> void:
machine.on_ground = true machine.on_ground = true
var speed := Vector3(vel.x, 0.0, vel.z).length() var speed := Vector3(vel.x, 0.0, vel.z).length()
if speed < params.slide_min_speed or elapsed > params.slide_duration: if speed < params.slide_min_speed or elapsed > params.slide_duration:
var shape: CapsuleShape3D = machine.player.shape_owner_get_shape(0) var end_shape: CapsuleShape3D = machine.player.shape_owner_get_shape(0, 0)
if shape: if end_shape:
shape.height = shape.height * 2.0 end_shape.height = end_shape.height * 2.0
machine.register_chain_mechanic("slide_end") machine.register_chain_mechanic("slide_end")
machine.switch_to("ground") machine.switch_to("ground")
return return
else: else:
var shape2: CapsuleShape3D = machine.player.shape_owner_get_shape(0) var fall_shape: CapsuleShape3D = machine.player.shape_owner_get_shape(0, 0)
if shape2: if fall_shape:
shape2.height = shape2.height * 2.0 fall_shape.height = fall_shape.height * 2.0
machine.on_ground = false machine.on_ground = false
machine.switch_to("air") machine.switch_to("air")
if not machine.input_crouch or not machine.input_sprint: if not machine.input_crouch or not machine.input_sprint:
var shape3: CapsuleShape3D = machine.player.shape_owner_get_shape(0) var cancel_shape: CapsuleShape3D = machine.player.shape_owner_get_shape(0, 0)
if shape3: if cancel_shape:
shape3.height = shape3.height * 2.0 cancel_shape.height = cancel_shape.height * 2.0
machine.register_chain_mechanic("slide_cancel") machine.register_chain_mechanic("slide_cancel")
machine.switch_to("ground") machine.switch_to("ground")
+1 -2
View File
@@ -55,8 +55,7 @@ func update(delta: float) -> void:
return return
# Lose wall contact # Lose wall contact
var still_on_wall := machine.wall_normal != Vector3.ZERO and var still_on_wall: bool = machine.wall_normal != Vector3.ZERO and detect_wall(machine.wall_normal).length_squared() > 0.0
detect_wall(machine.wall_normal).length_squared() > 0.0
if not still_on_wall: if not still_on_wall:
machine.wall_normal = Vector3.ZERO machine.wall_normal = Vector3.ZERO
machine.register_chain_mechanic("wall_run_off") machine.register_chain_mechanic("wall_run_off")