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

enemy doesn't follow the player

$
0
0
I'm using a simple enemy ai that makes the enemy follow the player, I am wanting to spawn my enemies one after the other which I have done, but for some reason the enemy only follows the player if both the enemy and the player are in the scene, in other words when I asiign the player as the target in the assets folder when both prefabs are in the assets folder the enemy only moves to the players start potition, is there anyway I can fix this script to accomindate my enemy spawners var Player : Transform; var MoveSpeed = 4; var MaxDist = 10; var MinDist = 5; function Start () { } function Update () { transform.LookAt(Player); if(Vector3.Distance(transform.position,Player.position) >= MinDist){ transform.position += transform.forward*MoveSpeed*Time.deltaTime; if(Vector3.Distance(transform.position,Player.position) <= MaxDist) { //Here Call any function U want Like Shoot at here or something } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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