Godot Version
4.2
Question
How do I make the on_area_3d_area_entered check for a specific scene
Sorry if this seems easy I’m really new to this
func _on_area_3d_area_entered(area):
One option is to use the Layer and Mask properties of your various collision objects. Layer is effectively “what layer is this collision object on?” and Mask is used for “what layer numbers do I respond to?”
For example:-
Set a secret door object/scene to be Layer 1, Mask 2
Set a friendly character scene to be Layer 2
Set an enemy character scene to be Layer 3
In your game when the friend enters the door’s collision area the signal will emit but when an enemy enters the signal will not emit.
The Area3D node has another signal that you can use, body_entered(Node3D). This gives you access to the individual scene/object that entered the area and you can then check it’s properties etc.
Combining these two approaches allows you to respond to quite varied situations such as the simple “A friend has entered, open the door” or the more complicated “An enemy has entered so don’t normally open the door, but this particular enemy has collected a key so let it through”
Use groups
Example:
func _on_area_3d_area_entered(area):
if area.is_in_group("player"):
print("Player entered")
if area.is_in_group("enemy"):
print("Enemy entered")
@gridsquat’s method works, but it’s a little bit too complicated ![]()
Thanks now I can make my enemies and state machines