I'm trying to deal with units (generated from the same prefab) dealing damage to each other on collisions. Each Unit has both a Collider2D and a trigger on the front, that deals damage to other units that enter it.
The problem I am having is that when a collision occurs (one unit enters the trigger of the other), both units damage each other, meaning Unit 2 also deals damage to Unit 1.
I have seen that you can create a separate gameObject as a child of the unit and attach the trigger to this gameObject.
However, the number of units will be very high so if possible I don't want to double the number of gameObjects used by units.
Also, the amount of damage dealt is calculated from many other parameters from many other scripts on the units and doubling all those references doesn't look like an elegant solution.
Any Ideas? Thanks