![]() Var hit : RaycastHit // cast a ray from mouse pointer: Var index : int = targets.IndexOf(selectedTarget) if we have the last target in the list, then get then first target in the list if we do have an enemy targeted, then get the next target if we do not have an enemy targeted ywt, then find the clostest one and target him Var sqrMag2 : float = ( targets.position - myTransform.position ).sqrMagnitude Var sqrMag1 : float = ( targets.position - myTransform.position ).sqrMagnitude Public function AddTarget(enemy : Transform)įor ( var e : int = 0 e < targets.Count - 1 e ++ ) Var go : GameObject = GameObject.FindGameObjectsWithTag("Enemy") Thank you in advance if you can help or point me in the right direction. When a target is destroyed it then wont select any other targets I also have a mouse click that selects target and that works fine, I think the problem is Function start and I have moved the parts to Function update but it just gives me errors because the Enemy Targets array just keeps growing. Hello I am nearly getting there with a Target script in JavaScript when I press tab it will select an enemy and tab again cycles through from closet to furthest away.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |