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

2D enemy AI

$
0
0
Hi, I'm currently working on a 2d game but I'm stuck on the enemy AI.I want it to go to the target which the player. I've shearched on the internet but there wasn't any tutorials. I've tried myself but I have a problem with transform.LookAt() which isn't for 2D. Here is my script : var Player : Transform; var Speed = 4; var Dist = 5; function Start () { } function Update () { transform.LookAt(Player.transform.position); if(Vector3.Distance(transform.position,Player.position) >= Dist) { transform.position += transform.forward*Speed*Time.deltaTime; } } Thanks for you help.

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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