I am simply trying to make a cube go from one place to another and then be destroyed. I am new to JavaScript. Thank you for your help. Here is the script:
function Start () {
}
function Update () {
Square ();
}
function Square () {
var ZAxisStop : boolean = true;
while (ZAxisStop)
{
gameObject.transform.Translate(0, 0, Time.deltaTime * -2.5);
if(gameObject.GetComponent(Transform).position == Vector3(229, 0.5, 227))
Destroy (gameObject);
break;
}
}
Thank you :),I am trying to make a cube simply go from one place to another and be destroyed using JavaScript. When I run it, it is never destroyed, it just keeps going. Please help me. This is my script:
function Start () {
}
function Update () {
Square ();
}
function Square () {
var ZAxisStop : boolean = true;
while (ZAxisStop)
{
gameObject.transform.Translate(0, 0, Time.deltaTime * -2.5);
if(gameObject.GetComponent(Transform).position == Vector3(229, 0.5, 227))
Destroy (gameObject);
break;
}
}
Thank you:)
↧