0 votes

Can anyone help me understand what Area2D Nodes are for.
Can you also list some real-world examples please?

Thanks!

in Engine by (24 points)

2 Answers

0 votes

Area2D is for detecting contact or overlap. It's for when you need to know if two objects are overlapping.

There's a good overview of it here:
https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#area2d

A couple of examples:

  • Collectible - You can use an Area2D for a pickup object, such as a coin. It detects when the player object enters its area, so you can remove the coin and give the player a point.

  • Area of influence - You need to have a region on your map that applies some effect: mud slows the player down, security camera can see the player in a certain area, etc.

  • Overriding physics - You can alter physics properties within a certain region, such as adding gravity around a planet or making a player float when in the water. Rigid bodies (which are controlled by physics) will be affected by the area's altered physics when inside the region.

You can also see the Official Tutorial Game, which uses an Area2D to represent the player, detecting when it contacts a mob.

by (20,891 points)
0 votes

actually, it looks like a security camera. it detects objects in itself but it's not static. they have a lot of use. for example a bullet. when something enters area of bullet, it detects it, use body_entered(node body) signal and connect it to bullet itself. then put body.damage() in it. with this simple area, you don't have to have a lot of code like in kinematicbody.

by (82 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.