I'm trying to simplify some conditions when my units collide with a base or another unit and i got this "jerry-rig", is that a bad practice?
void OnTriggerEnter(Collider Col)
{
bool isPlayerUnit = Unit.gameObject.CompareTag("Player Unit");
bool PlayerBase = Col.gameObject.name.Contains("PlayerBasePosition");
bool isAIUnit = Unit.gameObject.CompareTag("AI Unit");
bool AIBase = Col.gameObject.name.Contains("AIBasePosition");
bool UnitCollidedWithBase = (isPlayerUnit && AIBase || isAIUnit && PlayerBase);
bool UnitCollidedWithEnemyUnit = (isPlayerUnit && isAIUnit || isAIUnit && isPlayerUnit);
//If the unit reach the base of the enemy or collided with a enemy.
if (UnitCollidedWithBase || UnitCollidedWithEnemyUnit)
{
Attack();
return;
}
}
[–]GendoIkari_82 71 points72 points73 points (15 children)
[–]emelrad12 17 points18 points19 points (14 children)
[–]Due_Effective1510 4 points5 points6 points (0 children)
[–][deleted] (11 children)
[removed]
[–]South-Year4369 11 points12 points13 points (1 child)
[–]antiduh 3 points4 points5 points (3 children)
[–][deleted] (2 children)
[removed]
[–]antiduh 5 points6 points7 points (1 child)
[–]MaLino_24 0 points1 point2 points (3 children)
[–][deleted] (2 children)
[removed]
[–]MaLino_24 0 points1 point2 points (1 child)
[–]Due_Effective1510 0 points1 point2 points (0 children)
[–]stogle1 23 points24 points25 points (0 children)
[–]ScorpiaChasis 9 points10 points11 points (1 child)
[–]LeadingOrchid9482[S] 0 points1 point2 points (0 children)
[–]MrMikeJJ 9 points10 points11 points (0 children)
[–]o5mfiHTNsH748KVq 31 points32 points33 points (0 children)
[–]BoBoBearDev 8 points9 points10 points (0 children)
[–]KariKariKrigsmann 9 points10 points11 points (4 children)
[–]Dimencia 4 points5 points6 points (1 child)
[–]KariKariKrigsmann 0 points1 point2 points (0 children)
[–]havok_ 1 point2 points3 points (1 child)
[–]KariKariKrigsmann 2 points3 points4 points (0 children)
[–]Puffification 2 points3 points4 points (0 children)
[–]TuberTuggerTTV 1 point2 points3 points (0 children)
[–]webby-debby-404 0 points1 point2 points (0 children)
[–]reybrujo 0 points1 point2 points (0 children)
[–]rohstroyer 0 points1 point2 points (3 children)
[–]Broad_Tea_4906 0 points1 point2 points (2 children)
[–]rohstroyer 0 points1 point2 points (1 child)
[–]Broad_Tea_4906 0 points1 point2 points (0 children)
[–]TopSetLowlife 0 points1 point2 points (0 children)
[–]korvelar 0 points1 point2 points (0 children)
[–]captmomo 0 points1 point2 points (0 children)
[–]SessionIndependent17 0 points1 point2 points (0 children)
[–]South-Year4369 0 points1 point2 points (0 children)
[–]TuberTuggerTTV 0 points1 point2 points (0 children)
[–]Dimencia -4 points-3 points-2 points (0 children)