Godot Version
4.3
Question
I already read the Docs on this topic, but cannot figure out how this works.
All i have is Player(Body2D) with a Child-Area2D (The Hitbox).
And now if i enter the killzone_scene (whitch is just a Area2D) i want to make sure, the player is the only one, who can trigger it.
My Code in my Player
extends CharacterBody2D
class_name player
My Code in Hitbox
extends Area2D
class_name bird_player
Both the Player and the Hitbox itself are in the (Global) Group “Bird Player”
So how do i make my script work. I think its maybe another syntax mistake
Code in my Killzone
func _on_area_entered(area: Area2D) -> void:
print(area.get_class() + str(area.is_class("bird_player")))
#print out - Area2Dfalse
if area.get_class() == "bird_player":
pass
if area.is_class("bird_player") == true:
print("THATS IT")
#Rest of the function
if Gobal.player_can_die == true:
Gobal.dying()
set_deferred("monitoring", false)
print("You Fall of the World")
So why is my area.get_class() not bird_player ??
Is Classes the right way to do this?
idk i think there must be a easy solution, but i don’t get it