Instantiating a GameObject in Unity

Timo Schmid
Apr 7, 2021

--

We have the following objective:

We want to instantiate a Sphere GameObject whenever we hit the Space key.

At first, we have to create a new GameObject and prefab it for easy usage in scripts.

Next up, we need to assign the prefab in the script, so that we can use and instantiate it by just calling it inside the script.

We want to instantiate this Sphere every time when the user hits the Space key. For this, we check the input with the Unity Axis Manager.

After that, we want to instantiate the Sphere at the player position.

The end result will be this one:

--

--

Timo Schmid
Timo Schmid

Written by Timo Schmid

The mission? Becoming a game developer! RPG is the dream! Writing down my journey here for me and for everyone interested. Thanks for showing interest :)

No responses yet