Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development How to Make a Video Game Pickups Spawn Pickups Randomly

The variable flyPrefab of FlySpawner has not been assigned

I think there error for me has come through from the last tutorial, because I can't change the name of 'GameObject' to 'Game Manager' in the scene object window, it just goes back to 'GameObject' every time I enter the text.

My next mistake was that I didn't press 'apply' before I deleted the fly.

Then when running the game pressing play so flys spawn and I get this error...

UnassignedReferenceException: The variable flyPrefab of FlySpawner has not been assigned. You probably need to assign the flyPrefab variable of the FlySpawner script in the inspector. UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineObjectBindings.gen.cs:54) UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:144) FlySpawner.Update () (at Assets/Scripts/FlySpawner.cs:37)

Please help, I know what I did wrong (I think) but I can't repair it

Can you provide your code?

IMPORTANT NOTE:

If you don't format code, your code will look like this (using the Python language in this example):

def hello(name): print("Hello, {}".format(name)) print("Wuzzup?")

However, if you put the code in this (if you want to post C# code you should replace the Python word after the backticks with c#):

```python

def hello(name): print("Hello, {}".format(name)) print("Wuzzup?")

```

Note: By default Treehouse gets rid of all newlines so the code above is jammed together. But just read on to know how to fix that...

And it'll look like this:

def hello(name):
    print("Hello, {}".format(name))
    print("Wuzzup?")

Please provide formatting also :)