I figured out that when forage’s collision layer is 1st, the player will take damage by skeleton, when it passed forage’s collision. But when I change forage’s collision layer to 3rd, the player can’t pick up any forages, because it’ll ignore that. Even I added 3rd collision layer to the tilemap. I think I messed up… anyway, there’s any solutions?
I think it would be best if you could define the layers first.
Layer 1: Player Layer
Layer 2: Enemy Layer
Layer 3: Item Layer
then define the Masks of the Player and the Enemy.
First of all, the Player should Mask the item and enemy layer, the enemy in turn should only mask the player layer. I don’t believe the items need to have to mask anything.
from the provided screenshots, I don’t have info of the player but I believe the player never differentiates what his area is colliding with?
func _on_player_hitbox_area_entered(_area):
# check the area if it's an item or an enemy
var object: String = get_origin(_area)
if object == "Item": _current_area == _area
Of course this is just pseudocode but your _on_player_hitbox_area_entered can actually be triggered by an enemy or an item if your hitbox_area is masking both layers.
Either you have one area for each type or you need code to differentiate the entered_area’s origin.