- Home /
AI Enemy script
i'm having requirement to my game i.e.,enemy wants to attack on a gameobject(character or model) with different actions at different range of distance.
can anyone suggest me the way to write the script and explain the same?
thanks in advance...
Comment
Answer by Crispinator · Dec 16, 2013 at 01:19 AM
Use this distance script to set permitters for how you want your AI to act at certain distances.
var distance;
var target : Transform;
function Update ()
{
distance = Vector3.Distance(target.position, transform.position);
if(distance < whatever you want)
{
Do what you want
{
else if(distance < whatever you want)
{
Do what you want
{
Your answer
Follow this Question
Related Questions
Enemy Attraction/Aggro 1 Answer
Checking name from hit from Raycast in array 2 Answers
Need help with enemy AI 1 Answer
Collisions not working when player stands still 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers