basically i start the game but i have problem with targeting game objects
wondering if anyway can find any problem
the mobs are spawned into the game so would that impact anything?
and what needs to happen is they spawn in and they then select a defense out of the 4 defenses available once it has 0 hp then they move on onto the base but if the character gets in the way it will change to that target
using UnityEngine;
using System.Collections;
public class MobAiEast : MonoBehaviour {
public float preceptionradius = 10;
public float BaseMeleeRange = 4;
public Transform target;
public float Nill = 0;
public Transform _myTransform;
public Transform _east;
public Transform _base;
public Transform _player;
public GameObject East;
public int random;
public GameObject[] Defense;
void Start () {
random = Random.Range(0, 5);
Defense = GameObject.FindGameObjectsWithTag("east");
CharacterController cc = GetComponent<CharacterController>();
if(cc == null) {
Debug.LogError("no controller");
}
else{
}
East = Defense[random];
_myTransform = transform;
GameObject Player = GameObject.FindGameObjectWithTag("player");
GameObject Base = GameObject.FindGameObjectWithTag("Base");
_east = East.transform;
_base = Base.transform;
_player = Player.transform;
_east = target;
}
void Update () {
Defense other = East.GetComponent<Defense>();
if(other.CurHealth == 0 || other.CurHealth < 0) {
if(Vector3.Distance(transform.position, _player.transform.position) < 8) {
target = _player;
}
else
target = _base;
}
else
target = _east;
if(target){
goes on with moving to target stuff (can ignore i know it works :P)
thanks for any help!