Currently I have a targeting system that relies on OnCollision to then call a method on the GameManager then the Manager Script calling to the player. I’m satisfied with how the collisions are working at the moment but the way the structure is set up seems like it would be performance heavy if multiple enemies are in one scene. It looks something like this.
This function could be called multiple times in one scene because the player would be constantly switching targets
Enemy is hit by attack! > Passes Object Name of Enemy to Function in GameManager > Function then calls Function on the Player Script.and does its thing checking for positions etc.
Here are my concerns related to FindObject.
Each Enemy will need to have this in their Awake()
gameplayManager = GameObject.FindObjectOfType<scr_GameplayManager>();
Performance Based Questions: 1.Is FindObject only a problem when it’s being used to find different objects or the number of instances its used? 2.Is it better to create an Enemy Script containing AI based on what the enemy type is or create separate scripts?
3.Does creating multiple conditions for one command cause more performance issues then just running multiple commands? I.e. if(playerHealth <= 1 && canHeal == false || enemyThreat == true)