Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Track only closest enemy transform

$
0
0
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().enabled = true; } } } Thanks

Viewing all articles
Browse latest Browse all 1488

Trending Articles