Health Bar script Compiler Errors

I’m trying to write a script for a FPS game that i’m working on for class, but I keep getting compiler errors. The script I’m working with is a script that I’m modifying from a video that’s about two years old.
Where it says “UpdateHealthBar” is where i’m getting the error. Any ideas?

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class HealthBarControl : MonoBehaviour {

public Image EmptyHealthBar_Image;
public Image FullHealthBar_Image;

public int playerFullHealt = 10;
public int currentPlayerHealth = 10;

void Start () 
{

}

// Update is called once per frame
void Update () 
{

}

public void OnCollisionEnter (Collision collision)
{
	if (collision.gameObject.tag == "Enemy")
	{
		if(currentPlayerHealth > 0)
		{
			currentPlayerHealth -= 1;
			UpdateHealthBar  (currentPlayerHealth);
		}
	}
}

}

@Lpelley

There is no UpdateHealthBar() method within the class shown. So, it’s more than likely that you simply need to implement the UpdateHealthBar() method and the error (which I’m assuming is that it cannot call something which isn’t defined) should disappear. Unless, of course the method is contained within a different class, in which case you will need to assign it a reference to call it.

Also, please post the actual error message that has been logged to the console as it helps immensely.

I hope this helped ya! :slight_smile: