NULL pointer error

The code that I’m using is from the old Survival Shooter that Unity used to host. I’m getting the error that damageImage is null, but I can see it in the Inspector. There is no actual image, I’m using the color attribute. I’m hoping that I’m just missing something simple, but I’m not sure I’ve provided enough information. I’m using Unity 2021

void Update ()
{
    if(damaged)
    {
        damageImage.color = flashColour;
    }
    else
    {
        damageImage.color = Color.Lerp (damageImage.color, Color.clear, flashSpeed * Time.deltaTime);
    }
    damaged = false;
}

Then you haven’t completed step #1: find what is null.

The answer is always the same… ALWAYS!

How to fix a NullReferenceException error

https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/

Three steps to success:

  • Identify what is null ← any other action taken before this step is WASTED TIME
  • Identify why it is null
  • Fix that

color is an atribute of image. You need the image to be there. use a white plain image and you can adjust it color.