- Home /
2D Position of a game object.
Hi, my question is pretty simple. I'm just trying to get the X and Y position of my game object ( just a cube). After that I want to save these in a var. Btw I'm working in javascript. Thank you. -Nelis
Can you clarify what you mean? Do you want to coordinates for the object in the 3d world, or where on the screen it is?
Here are some links I strongly suggest to all new users :
Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/
this is the YouTube link for the above as one playlist : http://www.youtube.com/watch?v=-oXYHNSmTxg&list=PL27B696FB515608D2&feature=plcp
Answer by OmarAlhaddad · Feb 23, 2013 at 11:59 AM
you can use transform.position which gives you a Vector3 of world coordinates.
accessing the x and y can be done like this: transform.position.x and transform.position.y
Good luck