How to make enemy's collision to player, not the other way round?

Godot Version

I am using Godot 4.

Question

I have a player and an enemy in my 2D game.
The bug was ,even the player runs into enemy CollisionShape2D, the player took damage from the enemy.

How can i make sure when enemy attack only will deal damage to player?
Sorry if this is a newbie question, I have this bug unsolved. :frowning:
Please give advice on logic level, provide a sample if possible.

I’m not the type of type of person to answer questions here since I’m also new to the engine, but I think the problem is your collision layer and masks.

Try setting the player on 1 and 2 for both layer and masks for collisions then set the enemy mask on 2 but layer on 1, if it doesn’t work let me know, and I’ll try to see what your problem is :smiley: