0 votes

This might sound stupid, but is there a way to make Area2D collide 'physically' (as in not go through) other nodes (specifically a Kinematic Body2D for now).

I heard that Area2D nodes are the best to make a basic enemy. I am making a very basic top down shooter and I am wondering if I can make the enemies not go through the player and walls( when I add them eventually). The enemies do not instantly kill the player so they have to physically collide with him. I currently don't have any code in place that would do that. Is it even possible? or should I change the enemy node to a kinematic body or something else?

in Engine by (23 points)

3 Answers

+1 vote

I would use kinematicBody2d for the enemies. Area2d is more useful as a trigger than a collider imo. I.e it's good for transmitting onbodyentered signals to your scripts, allowing things like enemy starts to chase the player when in range and stuff like that.

by (19 points)
+1 vote

If you want kinematic body where player can collide but nothing else
see https://docs.godotengine.org/en/3.1/tutorials/physics/physics_introduction.html#collision-layers-and-masks
I don not know about area colliding but you can probably use both KinematicBody2D for collision and collision layers with it and area for collision detection

by (28 points)
+1 vote

You can have a KinematicBody2D as your main node of the enemy, Area2D as its child. The Area2D's collider should be a little bigger than the KinematicBody2D's, so they will inflict damage first, and be able to collide with the walls/player/other enemies.

by (56 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.