Hi, I literally started coding yesterday, and I’m following a guide on how to create an enemy with health bars. Here is the code I wrote
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class Enemy : MonoBehaviour
{
public int curHp;
public int maxHp;
public int goldToGive;
public Image HealthbarFill;
public void Damage ()
{
curHp--;
HealthbarFill.fillamount = (float)curHp / (float)maxHp;
if(curHp <=0)
{
Defeated();
}
}
public void Defeated ()
{
Debug.Log("Defeated");
}
}
In the guide he can post this onto unity with no problem, but when I do it VSC can’t find FillAmount to save its life. I made sure the health bar was on filled and everything, what am I doing wrong
Hi there! So the thing was I was using an old version of unity’s editor… And once I updated it, problem solved!
I wanna thank you for helping out as quickly as you did, I’m glad I will be able to get help quick when the inevitable mistake comes from me again!