Game Development Reference
In-Depth Information
possible to drag the bullet prefab onto the script to set the variable, you
can drag and drop any game object onto it, meaning that the rocket's
bullets could be any game object.
Listing 2.7 Instantiating a New Game Object from a Prefab
var aBullet: GameObject;
private var target: GameObject;
private var direction:Vector3;
. . .
function Update ()
direction=target.transform.position — transform.position;
. . .
//act on state
if(state == "ATTACK")
Instantiate(aBullet, this.transform.position,
else if (state == "RETREAT")
. . .
Fig 2.25 Setting a variable in a script
to the value of an existing prefab.
Search Nedrilad ::

Custom Search