From 210eef0e4179526f63bbfbc0a784238d1b93ac4b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 25 Nov 2023 14:14:59 +0100 Subject: [PATCH] Check for collision normal on horizontal collisions --- Player.gd | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Player.gd b/Player.gd index b86dfc2..254556c 100644 --- a/Player.gd +++ b/Player.gd @@ -12,6 +12,8 @@ class_name Player @export var max_jumps = 1 @onready var current_jumps = max_jumps +@export var collision_normal_max_y_for_floor: float = 0.9 + func refill_jumps(): current_jumps = max_jumps @@ -41,6 +43,12 @@ func _physics_process(delta): velocity.x += input_change.x * delta velocity.z += input_change.y * delta - print(velocity) - move_and_slide() + + # Gestisci collisioni + for collision_idx in range(get_slide_collision_count()): + var collision = get_slide_collision(collision_idx) + if collision.get_normal().y > collision_normal_max_y_for_floor: + continue + print("bonk") +