ScriptObject

Overview

Control all the scripts associated with objects. script may implements two object interface: Start and/or Update

Name Description Returns Parameters
Start called before any object updates, just once none Start({script})
Update called per frame none Update({script})

Start

Parameters

None

Exmaple

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
 //Create a Start function, this function defines the initial speed of an object
 //to a random float between 1 to 8
 AutoRtate = {
     speed : 0,
     objOption : null,
     function Start() {this.speed = util.randomFloat(1, 8);}

     // Create an Update function,
     //this function rotates the object a random degree along the Y-Axis every frame.
     function Update() {this.objOption.yaw(this.speed); }
 }

 var obj = object.create("AB052B5B646E4A48B9C045096FF9B088", Vector3(2.5, 0, 0));

 var script = obj.addScript(AutoRtate,"rotation");

 script.objOption = obj;

Update

Parameters

None.

Exmaple

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
 //Create a Start function, this function defines the initial speed of an object
 //to a random float between 1 to 8
 AutoRtate = {
     speed : 0,
     objOption : null,
     function Start() {this.speed = util.randomFloat(1, 8);}

     // Create an Update function,
     //this function rotates the object a random degree along the Y-Axis every frame.
     function Update() {this.objOption.yaw(this.speed); }
 }

 var obj = object.create("AB052B5B646E4A48B9C045096FF9B088", Vector3(2.5, 0, 0));

 var script = obj.addScript(AutoRtate,"rotation");

 script.objOption = obj;