Advertisement
Guest User

Untitled

a guest
Jun 12th, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Security.Cryptography;
  4. using UnityEngine;
  5. using UnityEngine.AI;
  6.  
  7. public class MinionController : MonoBehaviour
  8. {
  9. public GameObject enemyInnerTower;
  10. public GameObject enemyOuterTower;
  11. public GameObject allyInnerTower;
  12.  
  13. public float attackRange;
  14. public float aggroRange;
  15.  
  16. private NavMeshAgent minionAgent;
  17.  
  18. private bool hasTarget;
  19.  
  20. void Start()
  21. {
  22. minionAgent = GetComponent<NavMeshAgent>();
  23. hasTarget = false;
  24. }
  25.  
  26. void Update()
  27. {
  28. if (hasTarget == false) // focuses enemy outer then inner tower
  29. {
  30. if (enemyOuterTower.GetComponent<ManagerScript>().currentHealth > 0)
  31. {
  32. minionAgent.SetDestination((transform.position - enemyOuterTower.transform.position).normalized * (attackRange - 0.5f) + enemyOuterTower.transform.position);
  33. }
  34.  
  35. if (enemyInnerTower.GetComponent<ManagerScript>().currentHealth > 0)
  36. {
  37. minionAgent.SetDestination((transform.position - enemyInnerTower.transform.position).normalized * (attackRange - 0.5f) + enemyInnerTower.transform.position);
  38. }
  39. }
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement