Game Development Reference
In-Depth Information
Listing 2.10 Testing the Distance between Objects
var speed = 0.5;
private var target:GameObject;
function Start ()
{
target = GameObject.Find("Base");
}
function Update ()
{
this.transform.Translate(Vector3.forward * speed);
if(Vector3.Distance(target.transform.position,
this.transform.position) < 5)
{
print("hit");
}
}
Fig 2.26 Print messages showing up
in the message bar and console.
Search Nedrilad ::




Custom Search