+3

BOLT 101, or "Baby's First Game"

NeedsLoomis 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 22

Welcome to my attempt to explain the basics of BOLT by walking you through a simple game.  

This tutorial will be grown and maintained until I am happy with it or someone makes one better.

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

Excellent job. No doubt many in the community will find it useful.

Excellent job. I found it to be very useful. That will be the first tutorial video I create after I have finished the intro tutorial.

EDIT: I am so stupid. I was looking at it the whole time.

I just had to add another transition and in that one do a branch to test the scene variable.

Works fine now.


Hi, just puzzling how to get out of this state transition if a key is pressed?

Example: On another game object I have a flow machine looking for arrow key input and storing the bools in scene variables.

I would then like the transition of the cube moving left and right to listen for the scene bool variable and when it is true then jump out and move to another state.

How do I do this please, in playmaker I just say bool test and then finished when true.

You will take your scene bool, and compare it to a regular literal bool (check for true, uncheck for false).

You want to look for changes in the bool every frame, so make sure to put this in update.

I will go more into detail on the multiple ways to hook this sort of thing up later today, but you can branch this into another branch to check a different bool on false, run two of these in parallel, or run two of these each in a separate transition.

Edit: sorry, didnt see your edit, but Ill leave this up here in case anyone else needs it :)

Edit Edit:

Refactored as per eagleeyez suggestion, and extended to better show one of the solutions to the sort of thing he's talking about, this one without transitions.  Personally, I like to use transitions like he did when possible :)



Hi and thank you. You do not need Equal and bool. You can just test the scene bool directly with the branch. You then save 2 nodes.

I only had today another hour with bolt but have now realized that this is it. This is going to become more awesome than what it already is. I look forward to all that is coming.

Maybe we could make some tutorials together? I will hopefully have something to show on Saturday and if you like it then I could turn all written tutorials into video tutorials.

All the best Chris



You do not need Equal and bool. You can just test the scene bool directly with the branch.

Great catch!

Maybe we could make some tutorials together? I will hopefully have something to show on Saturday and if you like it then I could turn all written tutorials into video tutorials.

Feel free to do whatever you want with these :)  I'd be more than happy to help out or provide input.

Ok, my videos will now most probably be Sunday as I have been pushed into going to a wedding on Saturday.

Thanks

Chris

Updated with part 2, cheers all!

Great tutorial! :) Thanks for taking the time to write it, I know a lot of users were looking for a step-by-step introduction. Don't worry though, I'll be writing some similar tutorials myself in September. 

Just a little suggestion: instead of multiplying by delta time (two units), try using the Per Second unit, which does exactly the same thing behind the scenes and is a little more explicit!

I like your "hack" to use an event dispatcher for global custom events. In reality, I never expected the target port to be used this way. The object you pass there was intended to be the one that receives the event. For example, you could have attached a flow machine to your score indicator, and send the event there. But your approach makes sense as well, and I'll definitely include a target-less ("global") option when implementing custom event definitions.

Just a little suggestion: instead of multiplying by delta time (two units), try using the Per Second unit, which does exactly the same thing behind the scenes and is a little more explicit!

Oh hey, didn't realize BOLT had that!  I guess thats what happens when you buy a new toy and toss the manual aside :P

A global event would be nice, especially for the newer peeps.  I tend to use message and event systems in a very ECS sort of way, where my small bits and their systems broadcast between each other, so BOLT's way of doing things works well for me, but I wasn't sure how to go about making it simple for beginners, and delving into architectures seemed a bit heavy handed, so I just lumped it all onto one object :D

Hi, I like the new tutorial. I will be going through it now.

I’m getting a new headset tomorrow Plantronics Rig 500. I hope that this will be sufficient for audio recording as my current microphone sucks and I was not happy with the sound on my videos. I also am not going to the wedding tomorrow, so I can get stuck into some video making.  I sadly cannot afford a Sennheiser one or even the zero for that matter but the Plantronics sounds good for the price.

Hi,

I am not sure why you need the EventDispatcher when you are putting the receiving events on the game manager. Something is not clear here for me. I would just make an empty game object called Event manager and then all my receiving events would be put in that.

Btw. My new headset is rubbish and I will send it back on Monday to Amazon. Anyone know of a good mic that is not going to break the bank?

Hi again,

Why are you using a custom event on score? You could just add to the score variable on collision enter without having to transition to an event first.

I am just asking these questions as I like keeping things as simple as they can go. There is a saying in the technical world. “Why make things easy, if you can do it complicated?”

I however am looking for a complicated world refactoring to an easier world. That is where visual scripting could find its powers.

Hey NeedsLoomis can you please explain what you did there with your hack as Lazlo said. I would love to understand what you did. I can’t see the trees for so much forest.

Over the last few days I have been trying to get my cheap headset microphone to sound like a Ferrari and I even bought a new headset to realize that actually I should be purchasing a dedicated microphone and not a headset with one built in. Sadly, despite all my attempts it sounds like bicycle breaks and not a Ferrari.   

So I have now ordered the Auna MIC-900B and after reviewing many YouTube videos, I think I have found the cheapest and a really good microphone to do some awesome tutorials. The mic will arrive on Wednesday and I’ll give it a test drive for you guys.

Thanks again  NeedsLoomis for your tutorials. keep it up.


It's necessary to make tutorials. He makes people better accept Bolt!

Bolt is new, very new and I too am learning it bit by bit. You are going to get loads of tutorials from the community and the developer. Trust me! I am waiting for my new microphone as I could have started making video tutorials but as these tutorials are going to be hanging around a long time, then the sound and video quality should be up to standards. My mic will arrive on Wednesday and I’ll make an introduction to Bolt.

We support you! Looking forward to your wonderful tutorial!

 am just asking these questions as I like keeping things as simple as they can go. There is a saying in the technical world. “Why make things easy, if you can do it complicated?”

Its all good!  In the first tutorial I took a moment to show that refactoring and simplifying is always a good idea, so its great to take everything with a grain of salt and find better ways.

That being said, one reason I would want to trigger an event on score, as opposed to using a variable from the get go, is that a change in score is useful information that other systems may be interested in.  For instance, you may want a jukebox object that controls sound effects that will play a ding when it sees a point.  Detecting a change in a scene variable is more complicated than listening for an event.

However, the real reason I made things a little over engineered (using extra objects and events where we could have kept things bare bones) was simply an excuse to have the user create more events and transitions.   "In this section we add a character and control it (and other things) via events."  Which is to say, I don't need to use a chainsaw to cut a small branch, but at the end of the day, Im trying to teach someone how to use a chainsaw.  I'll look over the lesson and see if I can reinforce the topic through other means if it feels awkward though! 

Hey NeedsLoomis can you please explain what you did there with your hack as Lazlo said. I would love to understand what you did. I can’t see the trees for so much forest.

Custom Event Triggers need a place to broadcast their events.  Custom Events themselves need to listen to that place to receive the event.  Often you will broadcast directly to an object, and that object will listen to itself.  A hitbox object may broadcast to a health object that it got hit by a bullet.  The health object is listening to itself, so it sees the message when it arrives.  



But maybe you have a health object and a Halo style shield object?  We could have the shield listen to the health too, but that's a little weird and tough to debug later when you forget who listens to what, so maybe instead we reverse the system and the hitbox broadcasts to itself and all interested parties (the health and shield) listen to the hitbox!  But what if this is a monster that doesnt have a hitbox, and can only be killed by the sun?  The health doesnt know when it takes damage because it gets that info from the hitbox which doesnt exist!  Well, maybe we should listen to some other system, and both the sun and the hitbox will broadcasts to that...and so on.

 

Theres no correct answer here, these questions are common and a plethora architectures and programming methodologies have been invented to handle them, but for people new to bolt and messaging in general, its easier just to have a global object in the scene (what I called an event dispatcher) that does nothing but be broadcast to, and be listened to, by everything.  I made it a separate clearly labeled object, instead of using something already in the game (like Game Manager) so you dont accidentally delete it.  You may some day replace the game manager, forgetting that it also handled events, and accidentally break everything.

Hey, NeedsLoomis Thank you very much for your detailed explenation.

Cool, it makes sense now.

My fuzzy finder isn't picking up transform.translate. It doesn't appear when I search for it. The same thing happens when I attempt to look for the add torque for the rigid body. Did I do something wrong when setting up bolt?

Updating to v.1.1.3 should fix this!