Hey im trying to convert the C# Health script from Brug zerg arcade to a Javascript but a get an error
C# script
using UnityEngine;
using System.Collections;
public class PlayerHealth : MonoBehaviour {
public int maxHealth = 100;
public int curHealth = 100;
public float HealthBarLength;
// Use this for initialization
void Start () {
HealthBarLength = Screen.width / 2;
}
// Update is called once per frame
void Update () {
AddjustCurrentHealth(0);
}
void OnGUI(){
GUI.Box(new Rect(10, 10, HealthBarLength, 20), curHealth + "/" + maxHealth);
}
public void AddjustCurrentHealth(int adj){
curHealth += adj;
if(curHealth < 0)
curHealth = 0;
if(curHealth > maxHealth)
curHealth = maxHealth;
if(maxHealth < 1)
maxHealth = 1;
HealthBarLength = (Screen.width / 2) * (curHealth / (float)maxHealth);
}
}
My JS Script
var maxHealth = 100;
var curHealth = 100;
var healthBarLength ;
var adj ;
function start ()
{
healthBarLength = Screen.width / 2;
}
function Update ()
{
AddjustCurrentHealth(0);
}
function OnGUI()
{
GUI.Box (new Rect(10, 10, healthBarLength, 20), curHealth + "/" + maxHealth);
}
function AddjustCurrentHealth ()
{
curHealth += adj;
if(curHealth < 0)
curHealth = 0;
if(curHealth > maxHealth)
curHealth = maxHealth;
if(maxHealth < 1)
maxHealth = 1;
healthBarLength = (Screen.width / 2) * (curHealth / maxHealth);
}
The error i get
At line 13
thx