3
\$\begingroup\$

In my Scene I have a Node2D. I then Instanced the Player and Area2D nodes. The Area2D has a signal pointing to itself that prints test when run.

Here is the Code For the Area2D. Nothing happens when an object enters the Area2D.

extends Area2D

# Declare member variables here. Examples:
# var a = 2
# var b = "text"

# Called when the node enters the scene tree for the first time.
func _ready():
    pass # Replace with function body.

# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#   pass


func _on_Area2D_area_entered(area):
    print('test')

Level Scene
enter image description here

Player
enter image description here

Area 2D
enter image description here

Google Drive Link to Project: https://drive.google.com/drive/folders/1OG3BBqKJzC3Je_r5eQdqiFUp7PzzBmt1?usp=sharing

\$\endgroup\$
0
1
\$\begingroup\$

The question isn't entirely clear on what you want to trigger the signal, but I assume you want it to fire when the player enters the area. The docs for area_entered say:

Emitted when another area enters.

The player is a PhysicsBody, not an Area. Use body_entered instead:

Emitted when a physics body enters.

The body argument can either be a PhysicsBody2D or a TileMap instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.