Getting arguments from Area2D

Godot Version

4.7.2

Question

I am making a game where you have to stay on a track, and I want to detect when the player has exited the area that is considered the track so that I can make them lose, however I haven’t been able to find out how to implement this properly.

How do I get the Node that exited the track?

Use the body_exited signal.

How do I get the body that exited? I know the signal exists, but how do i find what exited?

Please check the link I gave you.

This still doesn’t explain how to use the body arguement. How do I get the body arguement? All you’re doing is sending me a link to something I’ve said I already looked at. At the very least can you show an example of code using the argument?

The body_exited signal gives you a Node2D as an argument. That is the body that exited the area. I’m not sure what else it is you need, could you explain why the body the signal gives you isn’t enough?

That’s very spoon feeding.

func _on_body_exited(body: Node2D) -> void:

The body is The arg on the func. The body!

Nobody is condescending, but giving us very little information to go off of means that it’s very difficult to give help. I cannot see your project or know how far along you are with godot specific knowledge.

It often helps to include examples that you have tried, and explain why they didn’t work, instead of vaguely explaining that “I tried something and it didn’t work.”

What do you want me to say? I didn’t get a single error message, the function just never happened in the first place.

Please check the following post: