0 votes

I have a n area2d in front of my player as the attack box but the enemy's area2d always detects it, how can i make it so that the enemy will only detect when the player attacks

in Engine by (394 points)

2 Answers

0 votes

You can make it so that the player node handling the input toggles the Area2D's monitoring and monitorable properties to essentially blind it and make it invisible to other Area2D's. In 2.1, I believe that would be with set_monitoring(bool) and set_monitorable(bool), but I'm not 100% sure. If nothing else, you can just do area2d_node.set("monitorable", false) to make it invisible.

by (184 points)
0 votes

From the player side, do a player_attack_area.get_overlapping_areas() when the attack is active, that should give you the list of enemy areas in the attack zone.

by (7,874 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.