Nilson 3 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 4

I'm not a programmer, I'm an illustrator. I was using playmaker and recently I moved to Bolt. I noticed that in Bolt the logic is identical to that of programming and not like in Playmaker, where there are several pre-fabricated actions. So due to this I started to study some C # programming. I have taken some tutorials in C # and converted to Bolt, so far so good :)
What I doubt is:
In C # first create a Variable and then save something in that Variable, eg:
SpringJoint2D sJoint2D;
sJoint2D = GetComponent <SpringJoint2D> ();

In this link you have an example tutorial in C #:

I did it the way it is in the tutorial, but in Bolt, I created all the Variables and then using as the tutorial requested.

I want to know if this is a correct way to work with Bolt? or if you do not need to create all these Variables

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

You don't "have" to, as long as you set them before you get them you don't need to create the Variables first. 

But there are situations where you will need to create the variables first so they are created before init to prevent errors. If you are not sure I would probably create them before hand and can type them to null before setting them if needed.


Just like in programming, there are many ways of doing the same thing.

  • You can define the variable beforehand in the variables window, if you need it to have a value before anything even happens in the game
  • Otherwise, you can create the variable "on the fly" in the graph. Using a "set variable" node will create a variable if it doesn't already exist.
  • Additionally, you rarely need to explicitly call GetComponent with Bolt. These calls are automatically handled in the connections (e.g. you can connect any component type to any other). If you're worried about speed, you can cache them, but I'd say this is almost always premature optimization.

Maybe it is premature optimization, but as I am new to bolt, but not to c#: How would I cache a component, for example the objects transform or an amimator? In start I set an object variable of the type animator, but how do I get the objects animator?

In Bolt, components are fetched automatically. At this point, I would consider it premature optimization. When Bolt 2 is released with code generation, component reference caching will be considered and done automatically if possible.