I'm trying to use the same bullet scene for all actors that fire bullets, but I want to resolve friendly fire and actually have the bullet to hit the proper target.
I know that you can change the collision mask in code, but I don't know how to do it for an Instance like the bullet instance.
The Bullet scene has an Area2D child for detecting collisions.
I have a Shoot function that creates the instance of the bullet, logically to me that would be where you'd change the collision mask of the Area2D Node child of the Bullet that would be set to mask a certain layer.
As of right now I do have both a player actor and an enemy actor successfully able to fire the same bullet but the bullet only damages the enemy, and it passes right through the player actor.
I did have this working the way I wanted by simply using two different bullets, one setup for the player to damage the enemy and one for the enemy that's setup to damage the player, but I want to try to reuse assets in the game, have a more professional project.
Thank you very much for your help.