breakable barrels

This commit is contained in:
2026-08-28 19:02:19 +03:00
parent 1021a07b04
commit 1eb06876e9
17 changed files with 4160 additions and 9 deletions
+13 -1
View File
@@ -1019,12 +1019,14 @@ func _physics_process(delta: float) -> void:
cube_guy.rotation.y = lerp_angle(
cube_guy.rotation.y, target_angle, delta * DP.f("visual_turn_speed"))
# Looping DASH clip while genuinely moving on the ground, idle otherwise.
# Looping WALK clip while genuinely moving on the ground, idle otherwise.
_update_locomotion_anim(on_floor and flat_speed > 1.0)
_pre_slide_vel_y = velocity.y
var pre_wall_vel := Vector3(velocity.x, 0.0, velocity.z)
move_and_slide()
# ── Wall bounce — no sliding, guaranteed exit ────────────────────────────
# pre_wall_vel is captured before move_and_slide strips the into-wall component,
@@ -1040,6 +1042,16 @@ func _physics_process(delta: float) -> void:
velocity.x = flat_n.x * exit_spd
velocity.z = flat_n.z * exit_spd
pre_wall_vel = Vector3(velocity.x, 0.0, velocity.z)
# --- ADD THIS BREAKABLE BARREL DETECTION CODE ---
var collision = get_slide_collision(i)
var collider = collision.get_collider()
# Check if the object we hit has the "destroy_barrel" function
if collider and collider.has_method("destroy_barrel"):
# Optional: Only break if moving fast (e.g., sprinting or dashing)
# if velocity.length() > 5.0:
collider.destroy_barrel()
# ── Landing. Don't bounce ─────────────────────────────────────────────────────
if is_on_floor() and not _was_on_floor: