Fixed object references cannot be set to object instances

my Laser Defender rep



reference has been placed
and when i play
but why is it still an error?

I’m stuck because I have followed exactly what was done in the video

1 Like

Hi,

Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

Check if your “singleton” calls gameObject.SetActive(false); in the same if-block where Destroy(gameObject); gets called. If there isn’t that line of code, add it.

Hope this helps. :slight_smile:


See also:

yes i have it in the ScoreKeeper.cs

Btw, i have fixed it
the start button can be pressed and it loads to the game scene, although the error sign still appears on the console.

I just had to move scoreKeeper.ResetScore(); under SceneManager.Load("Game"); line of code.

but its still not make sense, i think my Unity has error

Your Unity does not have an error. You dragged the prefab into the Start button’s click handler. The prefab does not have a reference to ScoreKeeper. You have to drag the instance in the hierarchy to the click handler

This is wrong

It should be this

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms