[Beginner, C#] Player's Area3D _area_entered signal connected, but cannot get it code working when entering another Area3D

Godot Version

Godot 4.2.2

Question

First, let me say I am very new and had no formal game programming class. So I am trying to code a generalized area detection for a game that detects an area and what group it is in, e.g. “ledge”, “cutscene”, “enemy”, and am first testing a ledge. I have an Area3D under my Player node, which is a CharacterBody3D, that connected the _area_entered signal to the Player. In a test scene there is a Ledge area (an Area3D node uniquely named Ledge in the tree) that I am trying to collide with this Ledge and just print in the output “Collided with ledge.” However, it’s not working; I do not see the print.

The Player’s Area3D has a CollisionShape3D that matches the mesh of the Player’s CollisionShape3D:

image

This is the signal connection with the Area3D child under Player:

image

The Ledge also has two CollisionShape3D nodes for the Area formal and for a StaticBody3D child to stop the player:

image

but the CollisionShape for the Area node is extended further away from CollisionShape of the StaicBody as I see in the viewport so the Player should be colliding with the Area first before the StaticBody walling them. The code is handled in Player.cs:

image

I checked the Ledge area’s group and it is spelled exactly like that, lower-case and all. I tried it with connecting the Area3D child signal to the Player in the GUI, as well as hard-coding the connection in the Player.cs script:

image

All other methods work in the Player.cs script, except I cannot get this print in the GUI Outputs nor an external console. I work on an Ubuntu machine and Windows machine interchangeably. Any help is much appreciated.

Looks like your script is with Timer, so for my case should I have a script in the Player’s Area3D handling the connection and what happens when an Area has entered? I can try that when I get to my code, but also I plan to change some properties under the Player given certain collisions between Areas. The tutorials I found had the Connect() and method definitions done in the connected node, i.e. the Player in this case.

Actually I found a solution to the problem. I was typing it in wrong for Callable in the _Ready() method for my Player. I don’t know why it was not giving me an error unless it was the base._Ready() overriding it somehow. Essentially in the player script I changed it to:

And it works, I see the prints in the output! Works without connecting on the Godot GUI for the signals. I also renamed the Player Area3D to a unique name, that may have helped. Experts can maybe explain further or correct me.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.