1
Fork 0
mirror of https://github.com/Steffo99/cinnos.git synced 2024-11-22 08:04:20 +00:00

Check for collision normal on horizontal collisions

This commit is contained in:
Steffo 2023-11-25 14:14:59 +01:00
parent c2373eaf9b
commit 210eef0e41

View file

@ -12,6 +12,8 @@ class_name Player
@export var max_jumps = 1 @export var max_jumps = 1
@onready var current_jumps = max_jumps @onready var current_jumps = max_jumps
@export var collision_normal_max_y_for_floor: float = 0.9
func refill_jumps(): func refill_jumps():
current_jumps = max_jumps current_jumps = max_jumps
@ -41,6 +43,12 @@ func _physics_process(delta):
velocity.x += input_change.x * delta velocity.x += input_change.x * delta
velocity.z += input_change.y * delta velocity.z += input_change.y * delta
print(velocity)
move_and_slide() 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")