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:
parent
c2373eaf9b
commit
210eef0e41
1 changed files with 10 additions and 2 deletions
12
Player.gd
12
Player.gd
|
@ -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")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue