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

Int value only changes after I stop playing

$
0
0
I made buttons that when I press them. it lowers the hp of the enemy in the scene, however when I press them nothing happens until I press the play button again to stop playing. After I do this it changes the int value and dosen't reset it to the default of 5. I put 5 buttons in the scene and clicked them all and nothing happened, when I pressed play again to end it and then hit play again it loaded the lose scene. Here is the code in question: using UnityEngine; using System.Collections; public class EnemyHealth : MonoBehaviour { public int ehp = 5; void Update() { if (ehp <= 0) { Application.LoadLevel("Lose Screen"); } } } ` and this: `using UnityEngine; using System.Collections; public class ButtonInteraction : MonoBehaviour { public EnemyHealth _enemyHealth; public void DamageButton(int damage) { _enemyHealth.ehp -= damage; } } The first is the script on the enemy and the second is the script on the button. Can someone help me with this?

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>