Le z-indexeur est là pour z-indexer tous ces petits gars

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
This commit is contained in:
Thomas
2025-02-22 09:21:28 +01:00
parent ec29c50631
commit 5721680834
9 changed files with 128 additions and 58 deletions

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://brh7cqaxc13ie"]
[ext_resource type="Script" path="res://zindex/z_index_controler.gd" id="1_fn0ft"]
[node name="ZIndexControler" type="Node2D"]
script = ExtResource("1_fn0ft")

View File

@@ -0,0 +1,22 @@
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