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

Enemy AI passing through walls

$
0
0
Though I have some tutorials and answers regarding enemy passing through walls but still didn't get it how to stop it? And so now I am attaching scripts. I know something should be added around the setdestination line but what?? void Update() { float distance = Vector3.Distance(target.position, transform.position); //x,y,z distance between target position //and our position if (distance <= 60f) { agent.SetDestination(target.position); //enemy will start chasing our hero (animations here) if (distance <= agent.stoppingDistance) { FaceTheTarget(); //face the target if (Time.time >= nextFiringTime && bulletreloadtime>0) { ShootTheTarget(); //attack the target (animations here) nextFiringTime = Time.time + 1f / 7f; //set timing intervals of enemy fire bulletreloadtime--; } if(bulletreloadtime==0) { bulletreloadtime = 40; //bullets are reloaded nextFiringTime += 2.5f; //bullet is reloading, time for reloading } } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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