The question is answered, should have been closed 6 years ago.
Getting an object's y coordinate
Note: those who have a low tolerance of n00bs may want to leave. xD
I just switched over from "Game Maker" to Unity 3d, and thank God I did! I just need a simple answer to a simple question, as I am not very familiar with Unity3d's variables, or javascript at all in that matter...
Is there a built in variable for x, y, and z of objects? If so could you all tell me what it is and maybe direct me to where I can look up an answer to this kind of question without bothering all of you?
Thanks a thousand, Kevin
@$$anonymous$$evin, you don't need to apologise that much (or at all), but if you do want to avoid annoying people, then please read the FAQ carefully. It's the button at top-right, and is really a good idea. Also, in general for learning Unity, here's another good link to start with: http://answers.unity3d.com/questions/4897/how-can-i-start-learning-unity-fast
Answer by Mike 3 · May 08, 2010 at 01:43 PM
transform.position.y
http://unity3d.com/support/documentation/ScriptReference/Transform.html
Hello, what if you want to grab the position of a different object? For example I have object A and i want know object B's position - do i need to make an instance of object b on object b's script?
@cdm89 You really should open your own question, this one is dead and buried.
Answer by HolBol · May 09, 2010 at 12:42 PM
i'd use something like
function Update(){
print(rigidbody.position.y);
}
that's how i did it
problem here is that it'll throw an exception if you don't have a rigidbody attached - transform should be sufficient in Update for all cases
Follow this Question
Related Questions
How to create procedural objects from files? 0 Answers
Overriding App icon string for Android builds 1 Answer
Random.Range not working? 2 Answers