Beginner Bolt Tutorial: Instantiate Prefabs / Spawn Objects

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial we're going to recreate the instantiate prefab script using bolt if you aren't using bolt feel free to skip ahead I'm going to be using both bolt and c-sharp in this tutorial series here I have the start of our unity sandbox it's a simple scene just with unity primitive 3d objects I should say that bolt has already setup if you need help with that I'll put a link below create an empty game object I'm putting mine inside this cube let's call it ball maker click Add component and add a state machine click new and I'm going to save mine in a folder called macro in the flow graph right click on start and choose make self transition double click on the transition node and right-click add a unit add-on enter state at the top corners of the flow graph you can click on an icon which will bring out the panels for the graph inspector and our variables select on enter state and check out the graph inspector there you can see there's a toggle for co-routine co-routines are functions that have the ability to pause execution and then continue again where things left off that's exactly what we want for our script you can also see the variables panel we're gonna make two scene variables in the scene tab the first variable is going to be the wait time before another ball appears so let's call this variable weight between balls and then let's make that an integer let's add another variable because we're going to add random spin to the balls so type random torque and make that an integer as well back to the flow graph right click add unit and type wait for seconds connect the on enter state to wait and then way to trigger transition click and drag the weight between balls variable into the flow graph and connect it to the delay time click back to the top state of the state machine double click on start I've deleted update and on exit we want this flow to happen on enter on enter we want a game object let's add a unit game object instantiate I have a prefab of a sphere with a rigidbody on it from the last video I'm going to drag that into object we want the ball to appear at the position of the ball maker so let's type transform get position it also wants a quaternion value and rotation doesn't matter so let's just keep it zero zero zero I want all the balls to be nested in this ball maker object so for parent put self we also want a slight random spin to each ball at a unit type rigidbody add torque we want the add torque unit with XYZ and mode having a unique spin for each ball add some unpredictability for our physics lab let's add three random range units you can make one and press control D to duplicate the other nodes we're making it so that each ball can spin any direction that means we're going to need a positive value and a negative value to spin the other way first let's grab a random torque value and plug it into max I have mine set at 15 then let's multiply this value by negative one and plug it into minimum we also want these values to change every time this flow happens the on enter state flow will go in to instantiate through each random range unit and then to add torque add torque also needs our object from the instantiate unit last we want to add a destroy game object unit with a time variable feed the instantiate object into the destroy unit and I'll put ten seconds press play and you'll see the balls generating and each one will have its own spin an amazing thing about bolt is you can dynamically see the script working look at the output of the random range values and how they change with each ball okay that's it for this video and like I said I'm going to keep using c-sharp and bolt for this unity sandbox tutorial series I call kinetic lab alright thanks
Info
Channel: Home Mech
Views: 13,570
Rating: undefined out of 5
Keywords: unity, bolt, game development, visual scripting, unity for beginners
Id: XgJTGDN3hw0
Channel Id: undefined
Length: 4min 47sec (287 seconds)
Published: Wed Sep 05 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.