Player and Enemy Collision Problem

Godot Version

4.0.2

Hi Im making a project and I need help with collisions. There is an enemy scene and a player scene. I need the enemies not to have collisions among themselves. However I need the play to have collision with the enemies. How do I achieve this?
Thanks in advance.

You can assign groups to nodes.

I’m also fairly new to Godot, but what I did is

  • Assign group “Enemy” to all enemies

image

  • In your collision detector, check something like this
func _on_weapon_area_2d_body_entered(body: Node2D) -> void:
	if body.is_in_group("Enemy"):
		return

if you click on your chrachter body , in collision tab , you can use layers.
first for your player , for example choose layer 1 and in mask choose layer 2.

then in your enemy scene , choose layer 2 and in mask tab , choose layer 1
now , you disable another layers.

also you can do this for floor , wall ,…

i am sorry for my bad english skill

good luck

2 Likes

I dont’t know what I did but I set tilemap layer to 1 and 2 and mask to 2. For the player I set layer to 1 and 2 and mask to 2.
for the enemy I set the layer to 1 and mask to 2. Thankfully it works. Thanks for the help.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.