i get the following errors on my script:
Assets/Scripts/HUD.cs(27,21): error CS1502: The best overloaded method match for UnityEngine.GUI.Label(UnityEngine.Rect, string)' has some invalid arguments AND Assets/Scripts/HUD.cs(27,21): error CS1503: Argument
#2’ cannot convert float' expression to type
string’
My script HUD.cs contains the following code:
using UnityEngine;
using System.Collections;
public class HUD : MonoBehaviour
{
//create a variable to access the JavaScript script
private Health jsScript;
void Awake()
{
//Get the JavaScript component
jsScript = this.GetComponent<Health>();//Don't forget to place the 'JS1' file inside the 'Standard Assets' folder
}
//render text and other GUI elements to the screen
void OnGUI()
{
//render the JS1 'message' variable
GUI.Label(new Rect(10,10,300,20), jsScript.health);
}
}
and my JS code is the following:
var MaxHealth=100.0;
var health = MaxHealth;
var regenTime = 20.0;
var regenSpeed = 3.0;
private var timer = 0.0;
function Update(){
if(health <= 0){
die();
}
if(health>MaxHealth){
health=MaxHealth;
}
if(health < MaxHealth){
if(timer < regenTime){
timer+=0.1;
}else{
health+=regenSpeed/10;
}
}else{
timer = 0.0;
}
}
function die(){
}