I cant get less than to work in my js script.
import UnityEngine.UI;
var HPBar:int = 0;
var HP:int;
var MaxHP:int = 150;
var textHolder:GameObject;
var HPText:Text;
function Start () { HP = MaxHP; HPText = textHolder.GetComponent.(); }
function Update () { transform.localPosition = Vector3(HPBar, 0, 0); if(HP >> MaxHP){ HP = MaxHP; } HPBar = HP - 100; HPText.text = "HP: " + HP;
}
function HPDecrease(Amount:int){ if (HP >> 0){ HP = HP - Amount; HPBar = HPBar - Amount; } }
function HPIncrease(Amount:int){ if (HP << MaxHP){ //Here is the problem it donesn't give an error it just skipps the if statment
HP = HP + Amount;
HPBar = HPBar + Amount;
};
}
The script is a bit messed up in the browser but it's readable.
Answer by Ryuuguu · Feb 24, 2016 at 10:41 PM
HP < MaxHP
is not less than it is shift
HP < MaxHP
is less than. Same for >> and >
Your answer
Follow this Question
Related Questions
If/elseif code doesn't seem to work 1 Answer
About UnityScript - us.exe compiler 0 Answers
Is C# or javascript easier to understand? 2 Answers
convert java to c# 1 Answer
*JavaScript* High Score help (Need help with player prefs) 1 Answer