Bolt - Instantiate Game Objects

With the click of a button, we can add game objects to the scene within a given area.

Bolt - Instantiate Game Objects
Example of what we will make

Requirements

  • Super basic Unity knowledge
  • Bolt 1 installed from the asset store
  • Level: Beginner (Although if you don't know Bolt you'll get the basics here)

A replay of the Flow Machine below being created

1. Adding baisc objects to the scene. Reseting transforms so objects are centered

2. Add a sphere gameobject. Make sure it's centered. Drag it into the Assets frolder to make a prefab. Delete it from the Hierarchy

3. Add a Bolt Flow Machine to the Waypoints game object. Add two variables of type game object to the inspector.

4. Drag our prefab variables into the graph. Then add the instantiate node. This is the node that adds our prefab to the scene. 

5. We use the inside unit circle node to give us random x and y values. We then mutiply those values by the size of the groundplanes bounds. 

6. We plug this new Vector3 position into the Instantiate position input. This will add our sphere to the scene at a random position on top of our ground plane. 

7. I want more Spheres in the scene. To do this we need a for loop and a number to count up to.

8. It's a little annoying hitting play all the time to add spheres. Lets add a button via the Hierarchy.

9. Plugging a button variable into the On Button Click node lets us add spheres via a button press. However i want the old spheres to be removed. Lets do that next. 

10. Now when we click the re-generate button we remove all the spheres first before making new ones.