So heres the thing, I started my tutorial, everything was going good and then bam, this line doesn’t work, I have no idea why, there is a similar line above it and it works. The last one referencing Lives.currentLives doesn’t work.
var damage : int = 25;
var player : GameObject;
var loseLife : int = 1;
var spawnPoint : Transform;
function OnTriggerEnter (player : Collider) {
player.gameObject.GetComponent(PlayerHealth).currentHealth -= damage;
Debug.Log(player.gameObject.GetComponent(PlayerHealth).currentHealth);
}
function Update() {
if(player.gameObject.GetComponent(PlayerHealth).currentHealth <= 0) {
player.transform.position = spawnPoint.position;
Debug.Log(player.gameObject.GetComponent(PlayerHealth).currentHealth);
player.gameObject.GetComponent(PlayerHealth).currentHealth += player.gameObject.GetComponent(PlayerHealth).maxHealth;
player.gameObject.GetComponent(Lives).currentLives -= loseLife;
}
}
Thanks
Khelton