Node Copied to Clipboard!

Editor Documentation - Nodes


Variables

Variables are powerful and have multiple uses in Modest3D.

The scene was setup with three cubes and the cubes are named to match their color, with a label right above the center cube.

The three cubes are dragged from the editor window to the story border. Then attached a wait for click and a loop, then all three strings are attached to a fork.

Now we are going to create a static Variable, if you hit the arrow to add a template tab

Add a Variable by right clicking on the Lesson text and selecting Variable

Change the Name & Type of the Variable, for this example we will select String type Variable

Variable Name

  • Name - Will represent the name of the variable/function

Variable Type

  • Bool - Variable represents either true or false
  • Int - Variable represents a round number without decimals
  • Float - Variable represents a decimal number
  • String - Variable represents text
  • Vector2 - Is a 2d position and is usually used for positioning things on the screen
  • Vector3 - Is a 3d position and is usually used for positioning things in the 3d scene
  • Quaternion - Is a 3d rotation. These are used for storing what direction a 3d object is facing

After naming & selecting a variable type, you will be able to populate the variable by right clicking in the story border and typing the name of the variable you have created

De-reference the Variable node by right clicking & dragging the bottom handler. Then start typing change to, to populate the Change To node

From the upper left handler of the Change To node.right click and drag. Type String Constant to populate a string constant node

Select the String Constant Node, and edit the value in the properties menu to match it to the name of the cube. Repeat the previous step for the other two strings

Drag the Label from the editor window to the story border.

De-reference the Label node by right clicking & dragging the bottom handler and select Text.

De-reference the Text node to populate the Change To Node.

Connect the upper left handler of the second Change To node to the Variable node on the left, connect the main flow of the first Change To node to the second Change To Node

Repeat the same step to the other two strings.

If done correctly, every time you click on a cube the name in the label should change to the cube clicked.

Node Example