Quand il rentre en action il trouve si quelqu'un est en collision Et il prend la hauteur de cette personne et se place au dessus Il est comme ça le zindexeur, il est sans gêne
23 lines
681 B
GDScript
23 lines
681 B
GDScript
extends Node2D
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
var hasManipulatedZIndex = false
|
|
if $ShapeCast2D.is_colliding():
|
|
var nbCollisions = $ShapeCast2D.get_collision_count()
|
|
for n in range(8):
|
|
var colider = $ShapeCast2D.get_collider(n) as Node2D
|
|
if colider != null:
|
|
(get_parent() as Node2D).z_index = colider.z_index+1
|
|
hasManipulatedZIndex = true
|
|
print((get_parent() as Node2D).z_index)
|
|
if !hasManipulatedZIndex:
|
|
(get_parent() as Node2D).z_index = 100
|