- Home /
Wrong if command
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?
As you seem to be struggling at this level, you should really do some beginner scripting lessons before moving further with your own project.
http://unity3d.com/learn/tutorials/modules/beginner/scripting
Answer by tanoshimi · Jan 05, 2015 at 09:50 PM
= 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).
Answer by joshmann971 · Jan 05, 2015 at 09:51 PM
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. :D
The question was about if statements, not Vector3. What is a choord?
Your answer
Follow this Question
Related Questions
Move an object toward an angle in 2d space 0 Answers
Rotation not going past 180? 2 Answers
AI movement using Character Controller, turning problem 1 Answer
if(Find.Child("thing");{ 3 Answers
LookAt Problem 1 Answer