In my project the same kinematic body can be used by player and enemy. When the punch_hit area 2d collides with Hurt_box area 2d a hurt animation plays. I want the Hurt_box to ignore this when it’s own punch_hit is colliding.
Any ideas aside from adding new groups to the Area_2Ds?
Set up the physics layer, and assign it in the editor it should automatically work.
The Docs has a set by step for a the basic set-up it should work.
Thanks. I will check it out. I was trying to make it so that any character can hurt any character like in Grand Theft Auto or Skyrim.
I’m using a script to assign ID to every generated NPC and that ID gets added as a group to the character’s collision so when the punch collides with the character’s own collision shape it checks if the ID is the same as it’s own and returns the function.
You could check it manually. In the code run when the two areas collide, verify if it is the sibling Node.
Edit, if you have a script in Hurt_Box : onready var own_punch = $"../Punch Hit" #“…” represents the parent Node. func on_Hurt_Box_area_entered(area): . if area != own_punch:#don’t punch yourself . . pass#all good, you can punch
Alternatively, if enemies can only hurt players, and vice versa, you can use collision masks. punch_player collides with hurt_enemy, and punch_enemy collides with hurt_player.
I wanted to make it like GTA or Skyrim where anyone can attack anyone. I just wanted the collision shape to not get triggered by their own punches.
Giving every character unique generated IDs works. After the ID is generated. Use var2str and add the area2d to the group var2str(ID). When area enter is being checked make sure your area doesn’t belong in var2str(This character’s ID).