- Home /
enemy doesnt go towards small object
Im making some sort of horror game. when you click, you throw a light (sphere with point light), im trying to make it so that the enemy destroys all existing lights and then goes after the player, the thing is he runs away from them. I increased their size to 1 on all axis'(previously 0.3) and he goes after them, but very slowly. I've searched for an answer and cannot find it. EDIT: i thought it would be usefull to know the brain of my enemy; so here it is:
public class BasicEnemyAI : MonoBehaviour {
public GameObject Target;
public float MoveSpeed;
// Use this for initialization
void Start () {
Target = GameObject.FindGameObjectWithTag ("Player");
}
// Update is called once per frame
void Update () {
if (GameObject.FindGameObjectsWithTag ("PlayerLight").Length > 0) {
transform.LookAt(GameObject.FindGameObjectsWithTag ("PlayerLight") [0].transform);
} else {
transform.LookAt (Target.transform);
}
transform.position += transform.forward*MoveSpeed*Time.deltaTime;
}
void OnTriggerStay(Collider other){
if (other.tag == "Player") {
Application.LoadLevel (Application.loadedLevel);
}
if (other.tag == "PlayerLight") {
Destroy (other);
}
}
}
Your answer
Follow this Question
Related Questions
Roll-A-Ball enemyball[Personal Extra] Cant get it to follow the player 2 Answers
How to make an enemy stop and start movement in a tower defence game? 0 Answers
How do I get GameObjects to look at me? 2 Answers
Merging my enemy AI and target script together smart? 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers