Knowledge Base - Your First Visual Script

In this document, you will learn the core construct of iCanScript by creating a visual script to move a sphere. We assume you have already installed iCanScript and you have opened a new Unity scene.

1- Open the iCanScript Editors

iCanScript comes with the following editor windows:

  • Visual Editor (main edition window);
  • Library Tree (from where you get your nodes);
  • Instance Wizard (object-oriented panel to work with object instances);
  • Tree View (same as Visual Editor but in tree format);
  • User Preferences Panel (to personalize the look and behaviour).

Open the Visual Editor, the Library Tree, the Instance Wizard and the Tree View and arrange the layout to your liking.

2- Create a Sphere Component

Use the menu GameObject->Create Other->Sphere to create the sphere object that will host the visual script.

3- Add the Visual Script to the Sphere

A Visual Script is a component that needs to be added to a game object:

  1. Select the Sphere game object and;
  2. Create the Visual Script using Component->iCanScript->Visual Script.

The Visual Editor will now display a canvas and is now ready to be populated with nodes.

4- Every Script Starts With a Message Handler…

Every script in Unity is invoked from a message sent by the Unity framework. Use the following steps to create the Update message handler for your visual script:

  1. Right click (or two finger click for Mac users) on the canvas of the Visual Editor;
  2. Select from the menu that appears the “+ Update

The Visual Script now contains a message handler that will execute when Unity send the Update message.

5- Accessing the Sphere Transform

Moving the sphere requires that you modify its transform component. Before you can do so, you will need to create a node representing its transform.

  1. Click and drag the transform port from the edge into the Update node;
  2. Release the port inside the Update node;
  3. Select “+ Object Instance” from the menu to create a transform instance node.

Have you noticed that the instance port (i.e. “this” port) is connected to the Update::transform port. This type of connection is called a binding.

6- Move the Sphere

Add the translate function to your transform instance node using the Instance Wizard editor by:

  1. Selecting the Transform instance node;
    • This will display the available variables and operations in the Instance Wizard.
  2. Scroll the Operations section of the Instance Wizard until you see “Translate(x:float, y:float, z:float)”;
  3. Click the “Translate(x:float, y:float, z:float)” to add the function to the node.

In this example, you will move the sphere in the X-Axis only with constant velocity. This can be realized by configuring the input ports of the translate function of the transform:

  1. Select the x.translate port of the Transform node;
  2. In the Inspector, open the iCS_Visual Script component;
  3. Modify the x.Translate attribute with the value of 0.2 (displacement/frame).

7- Run the Visual Script

Your visual script is now ready to run. Just press the run button and watch your sphere move in the x-axis.

8- What Have You Learned?

  1. Setup your environment to use iCanScript editors;
  2. Install a Visual Script;
  3. Create a message handler node to respond to Unity Update messages;
  4. Extract the transform instance node from the game object;
  5. Populate the transform node with the translate(…) function using the Instance Wizard;
  6. Configure the translate(…) function to move the sphere;
  7. Run the visual script.


Created : 2015-03-13 20:35:05, Last Modified : 2015-03-13 22:30:47

User Comments

Add a Comment

Melatonin - Buy Cialis Precio De Cialis De 5 Mg Cialis Viagra E Solfatare Lesinsops, @ 2020-03-06, 16:24

Search Articles

Member Login