I’m trying to make a zombie vs human simulator, but I can’t quite get the human to detect the zombie/zombies in the area using the tag “Zombie”, while they are in the Human’s Sphere Collider. Here is the Code:
using UnityEngine;
using System.Collections;
public class Z_Run : MonoBehaviour {
// Use this for initialization
public int vBubble = 100;
Transform target;
public int speed = 10;
bool isStay;
void Start () {
}
void OnTriggerStay (Collider other) {
isStay = true;
}
// Update is called once per frame
void Update () {
findTarget ();
transform.LookAt (target);
transform.Rotate (180, 0, 180);
transform.Translate (Vector3.forward * speed * Time.deltaTime, Space.Self);
}
void findTarget () {
if (isStay) {
target = GameObject.FindGameObjectWithTag("Zombie").transform;
}
}
}