Hi,
I am having a small problem which I don’t understand.
I am importing health script corectly in my EnemyAI but when it’s about taking damage I get the error that the component is not asigned.
public HealthBarGUI health;
void Awake(){
myTransform = transform;
controller = GetComponent<CharacterController>();
health = GetComponent<HealthBarGUI>();
currentWaypoint = WayPoint1;
.
.
.
.
.
void Attack (){
if( attackDelay == 0 )
attackDelay ++;
animation.CrossFade(attackAnimation.name);
health.curHealth = health.curHealth - maxDamage;
if( attackDelay > 3)
attackDelay = 0;
}
}
And the error I get is the following :
“Object reference not set to an instance of an object on line health.curHealth”
EnemyAIC.Attack