Hi I have this script…
#pragma strict
function Update () {
if (transform.position = Vector3(0, 100, 0))
//DoSomething
}
But i think “if” command is bad. How can I write command “if” object position then do somthing?
Hi I have this script…
#pragma strict
function Update () {
if (transform.position = Vector3(0, 100, 0))
//DoSomething
}
But i think “if” command is bad. How can I write command “if” object position then do somthing?
= is assignment. == is to test for equality.
if (transform.position == Vector3(0, 100, 0))
(although there’s still problems with that - a Vector3 is a vector of 3 floating-point numbers, and you should never test for equality between floating-point values).
I don’t know if this will help, but Vector3 is a point in 3D space, all relative to the object it is attached to/ referenced. The first number is the x choord, the second number is the y choord. and the third number is the z choord. Hope this helps.