How to use coliders in code?

Godot Version

Godot 4


Hi! I am new to godot. I want to create code that would check if my player is high enough (above half of the screen). I tried to use coliders, but I have no idea how to actually use them in code. I don’t know which signal I should use and how to attach it to script. I want to check if center_collision node is in coliding with player node, but can I do it in script that is attached to camera 2d? The idea is that camera moves with constant velocity up, but when player would hit the colider the camera would center on the player and start to follow them. Could someone explain to me how to do it? Thanks in advance!

thank you for the tutorial but unfortunetly I still can’t figure this out. I tried coding it like this:

I am shure I use correct signal because I tested it, but it’s still not working properly :frowning: . Furthermore, the area_center node is stying in place. I thought making it the child of the camera would make it move with the camera but it’s not.

:thinking: For what you’re trying to do, I would use Phantom Camera instead of trying to use colliders, etc. I mean it is possible to do by hand but this tool will make your life a lot easier for this particular case.