Notice: This article builds upon the visual script created in the Your First Visual Script article.
In this article, you will learn the four (4) methods of accessing the library content. In doing so, you will update the sphere movement created in the previous article to orbit the world center (0,0,0) using simple mathematical function nodes.
Starting from Your First Visual Script example, perform the following steps:
The Instance Wizard give you access to the variables and operations available on a specific class of object instance. You will use the Instance Wizard to remove the Translate(…) function and add the set_position property of the Transform component attached to the sphere.
In the visual editor, select the Transform node to activate the Instance Wizard.
In the operations section of the Instance Wizard, scroll to and click the highlighted Translate(x:float, y:float, z:float) to remove it from the Transform.
In the variables section of the Instance Wizard, click the input checkbox of the position property to expose it.
The sinus and cosinus functions will be used to orbit the sphere around (0,0,0). These functions will be extracted from the Mathf class included in the Unity Engine assembly.
To add the sin function:
Adding the cos function:
The Sin and Cos mathematical nodes produce separate floating point values. These values must be collated in a :Vector3 type to be bound with the position property of the Transform.
Creating the ToVector3(x:float, y:float, z:float) adaptor node:
Cleanup and bind the nodes:
To complete your script, you need to drive the input port of the Sin and Cos nodes with a time base function.
The script is complete and can be ran by pressing the play button. The sphere orbits the position (0,0,0) with a radius of 1.
Created : 2015-03-16 15:16:36, Last Modified : 2015-03-16 15:16:36