I’ve created a prefab called ‘Bullet’ and I’m trying to add it to the scene whenever a player presses space.
I have the following script set up:
void Update ()
{
if(Input.GetKeyDown(KeyCode.Space))
{
GameObject go = new GameObject("Bullet");
}
}
But when I hit space when the game is running I get an error saying ‘the thing you want to instantiate is null’.
And that’s basically what I probably should expect, but how do I make it a prefab of Bullets?
edit: I’ve found that I can do this by creating a public object variable and manually dragging and dropping the prefab into it from the window pane afterwhich I can simply Initialize from it. but I would rather be able to tell it to load a prefab I know I’ve created, is this possible?
Thanks for this answer, helped me fix my issue lol
– Lazouskie