I am trying to take this method from my HealthManager.cs
void LoadHealthSprites () {
//array index 0 is 1 hit
int spriteIndex = totalHealth -= 1;
//will only run IF the there is a sprite at index[x]
if (healthSprites[spriteIndex]) {
this.GetComponent().sprite = healthSprites[spriteIndex];
}
}
and execute it on my LoseCollider.cs:
void OnTriggerEnter2D (Collider2D trigger) {
if (HealthManager.totalHealth >= 3) {
HealthManager.LoadHealthSprites();
} else {
levelManager = GameObject.FindObjectOfType();
levelManager.LoadLevel("Lose");
}
}
I get an error on this line from the LoseCollider.cs:
HealthManager.LoadHealthSprites();
The error says:
error CS0120: An object reference is required to access non-static member `HealthManager.LoadHealthSprites()'
How do I create the reference to use the method?
↧