How can I achive that I’m only targeting the closest enemy?
Even better would be to “loose” the target if the target comes to close to the player. Jumping on the next target in range, if there is any.
Here is my code:
public class PlayerInput : MonoBehaviour
{
public Transform target;
void lookForTarget()
{
if (GameObject.FindWithTag("Enemy") != null)
{
target = GameObject.FindWithTag("Enemy").transform;
target.Find("TargetGui").GetComponent<Renderer>().enabled = true;
}
}
}
Thanks