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

Bug with my enemyAI

$
0
0
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"); } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles