I got a simple basic enemyAI script of the unityanswers, and i need some help with it it is for a First Person RPG Adventure game i am working on.
When the enemy chases you lose health, (heaps of health), When you should only lose one health, when the enemy is actually near you and attacking you. Here is the enemyAI script
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)
{
GameObject.FindGameObjectWithTag("Player").GetComponent(HealthBar).AdjustCurrentHealth(-1);
animation.Play("attack1");
}
}
}
↧