Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy walking through walls/terrain

$
0
0
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

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>