Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Damage System Doesnt Work?

$
0
0
Newbie Help please. I am trying to write a simple command that reduces my health by 10 every time i press A: var Health : float = 100; var MaxHealth : int = 100; var HealthBarTexture: Texture2D; var SelfDamage : int = 10; function TakeDamage () { if(Input.GetKeyDown(KeyCode.A)) { Health -= 10; } } function OnGUI() { if (Health <= 0) { Health = 0; } var HealthPercent = Health / MaxHealth; var left = 50; var top = 50; var MaxHealthBarWidth = 500; var HealthBarWidth = MaxHealthBarWidth * HealthPercent; var height = 50; //Health Bar Texture GUI.DrawTexture(Rect(left,top,HealthBarWidth,height), HealthBarTexture, ScaleMode.StretchToFill, true, 1.0); } Help please? Thanks

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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