Hi, I have a script for my two enemies in my game, and both of them will walk through walls and terrain regardless.
The Script is below:
using UnityEngine;
using System.Collections;
public class EnemyScript : MonoBehaviour {
public Transform playerLocation;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.LookAt(playerLocation);
transform.Translate(0, 0, 1 * Time.deltaTime * 10);
//GameObject.Find("GameObject");
}
void OnCollisionEnter(Collision collision){
if (collision.gameObject != null){
Destroy(gameObject);
}
}
}
What can I change to make it so they do not walk through walls/terrain
↧