Hello I’m getting this error:
NullReference: Object reference not set to an instance of an object
PlayerUI.Update() (at assets/PlayerUI.cs:19)
This is my PlayerUI script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerUI : MonoBehaviour {
[SerializeField]
RectTransform thrusterFuelFill;
private PlayerController controller;
public void SetController(PlayerController _controller)
{
controller = _controller;
}
void Update()
{
SetFuelAmount(controller.GetThrusterFuelAmount ());
}
void SetFuelAmount(float _amount)
{
thrusterFuelFill.localScale = new Vector3 (1f, _amount, 1f);
}
}
and this is is a snippet of my PlayerController script (where I get the method GetThrusterFuelAmount from):
[SerializeField]
private float thrusterFuelBurnSpeed = 1f;
[SerializeField]
private float thrusterFuelRegenSpeed = 0.3f;
public float thrusterFuelAmount = 1f;
public float GetThrusterFuelAmount()
{
return thrusterFuelAmount;
}