Where is bolt Function nodes?

Seyyid Doğan 4 years ago updated by Lazlo Bonin (Lead Developer) 4 years ago 11


What is the equivilant of this c# snippet in Bolt,

public class UIManager{

   public int DrawStuff(float x){


     return random(0,20);



public class Player{

   UIManager ui;

   void Start(){

      int x = ui.DrawStuff(.2f);

      //do stuff with x



I know it can be done with 2 custom events, but it would be way too hacky for doing this sort of stuff.

How to do this?

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Pending Review

Hi Seyyid! Welcome to the community :)

Have you tried using a Super Unit for this? They are the equivalent of functions in Bolt.

Documentation: http://support.ludiq.io/forums/4-bolt-manual/topics/154-super-units/

Thank you ^^

I belive super units are equivalent of macros. They are not connecting graphs to graphs. Its not like calling a function.

I might use some hacks to actually make a function of UIManager a macro. But it would make clutter as this gets more complex.

Isnt there any method to make a flow go like GraphA>GraphB>GraphA with some return values, and not with events.

I kinda maid it in a hacky way. But i still think this could look way much better.

Yeah I think you came from the same way as me. Thinking with class types in mind. Not how Bolt actually works though. Here is what I would do. Toss out all events. No need for them. And forget UIManager class even exists. All "Functions" can be use in any graph from here on out. Essentially always global functions.

1) Create 2 super units. Name one "Player" and the other "DrawStuff", make sure you convert them to Macros first. Should look like this: *Or you can create these by right clicking in a project folder and creating them as macros automatically.*

2) Double click to enter the DrawStuff macro, and add a Value Input called "XIn", and two Value Output called "XOut".and "Return". Change the labels to X on both XIn and XOut.. Change its type to float. Change result type to Integer:Then add in a Random > Range (Min, Max) unit from the fuzzy finder, change its max to 20, and connect its output to the Result output. Should look like this:

3) Now lets edit the Player..This Player I assume is your "Component". So make sure it is first added to whatever object will be the player. Then add a graph variable called "X" to player, Make "X" into a float. Add a "Start" event as well. Then drag out the start control flow and add Set X or Set Graph Variable, and name it x in the input string. Rightc click, add in the DrawStuff macro. Attach it's output X to the set graph variable. Then you are done. That would be the equivalent to the c ode you wrote.

I think i wrote this question a little bit wrong, so sorry for that. What i was actually asking was what if my UI manager actually did something depending on his object and graph.

let us assume  "//Stuff" actually is


this.gameobject.name = x.toString();




Then you couldnt just forget about UIManager. It is way too complex to just be a macro. Its functions are not pure.

ps. Notice that this code is Pseudo and just for demonstration purposes.

Replied right as I was posting. I get what you are saying. Don't think you can get around it without events. See my latest example, is this more what you want? I'm not going to redo it, but you should be able to create macros events that do those things, and just populate them in the graphs you want, and trigger them how I did.

Now yes you could also have a UIManager, but you will need to use events. But its pretty easy. I created embedded graphs to make the output values easily readable, but not necessary. So on a UIManager gameobject, you'd have this:

And on your player... this:

And if you want to call them sequentially how you have it, you could do this: a little hacky, but once the macro is finished, just reuse that function:

Then you get it only assigning to X I see. So maybe needed a little more. I've recently figured out most of the necessary parts to creating native units with the API. I very well may push aside my binary encryption unit, and take a look into a custom solution. I'll let you know if I come up with something. I will start tonight, because this is a very good point you brought up. Something I wanted when I first started, but found the way I showed you.


I ended up with a graph like this. Is not very optimized for sure, but it works.


Basically, what you are looking for here is called encapsulation, which is another word classes: grouping methods and data in one parent data structure (for example here the UIManager).

Bolt does not (yet) support encapsulation. It is not an object-oriented language. To support what you want, here is what would be needed to implement:

  • A new asset type & editor to define a class, with name, description, etc.
  • A new editor to define variables and method graphs for classes
  • New units to get / set class variables
  • New units to invoke class method graphs
  • A new machine component to run the class

Needless to say that this is a massive amount of work! I haven't decided against implementing encapsulation in the future, but because there are many workarounds, it is not a priority at the moment.

I recommend taking a moment to think and plan your game in a non-OOP mindset, using functions and events rather than classes. You will find Bolt to better suit your needs then. In a closer time frame, however, I want to implement custom event definitions to make events more reliable (see this idea thread).