Hello, I am new to Unity, and I need to create a health bar. My idea is to create the box, and in it, print the current health / max health. Here is my Boo script:
import UnityEngine
class PlayerHealth (MonoBehaviour):
public curHealth as int = 100
public maxHealth as int = 100
def Start ():
pass
def Update ():
pass
def OnGUI() as void:
GUI.Box(Rect(10, 10, Screen.width / 3, 30), curHealth.string '/' + maxHealth.string)
I get these two errors:
Assets/Scripts/PlayerHealth.boo(14,74): BCE0044: expecting “RPAREN”, found ‘/’.
Assets/Scripts/PlayerHealth.boo(14,100): BCE0043: Unexpected token: ).
What am I doing wrong? An answer in Boo would be great, but C# would also be fine if you need to. Thanks in advance.
Edit:
Well, Here it is:
def OnGUI() as void:
GUI.Box(Rect(10, 10, Screen.width / 3, 30), curHealth.ToString() +'/' + maxHealth.ToString())
Instead of .string, it is .ToString(). I also needed the + before ‘/’.