Enemy walking through walls/terrain

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

You’ll need to use rigidbodies to move rather than transform.translate. Translate essentially teleports an object to a new position, regardless of collision. Look up guides on Unity’s physics system for more info.

Also, when you implement the rigidbody, you may have to remove your oncollisionenter function, as it will destroy the enemy on every collision even when it hits the ground.