diff --git a/The project/Assets/Scripts/Soldier.cs b/The project/Assets/Scripts/Soldier.cs index 301af388..e7294ca9 100644 --- a/The project/Assets/Scripts/Soldier.cs +++ b/The project/Assets/Scripts/Soldier.cs @@ -13,14 +13,29 @@ public class Soldier : MonoBehaviour [SerializeField] private float speedAttack = 1; // Start is called before the first frame update void Start(){ + setEnemyTag(); + } + + public void setOwnTag(string tag) + { + gameObject.tag = tag; + } + + public void setEnemyTag() + { if(gameObject.tag == "Ally") enemyTag = "Enemy"; else enemyTag = "Ally"; - InvokeRepeating("UpdateTarget", 0f, 0.5f); - // Call UpdateTarget method at the begining of the Start() - // and repeat every 0.5 second - } + void Awake() + { + TickSystem.OnTick += HandleTick; + } + private void HandleTick(TickSystem.OnTickEventArgs tickEventArgs) + { + UpdateTarget(); + } + void UpdateTarget () { // Enemies are the game objects tagged with the "Enemy"