- Home /
How do I set and get the position of a object?
How do I set and get the position of a object in vector 3 form?
Edit: I am using C#
Comment
Answer by Dave-Carlile · Jan 31, 2013 at 03:18 PM
Assuming you're using C#...
transform.position = new Vector3(10, 20, 30);
Getting the position is just accessing transform.position
.
Vector3 p = transform.position;
Relevant documentation:
Answer by ixjackinthebox · Jan 31, 2013 at 07:41 PM
Thanks so much but how can I get the position in (x, y, z)
To just print in on console you type
using UnityEngine;
using System.Collections;
public class position : $$anonymous$$onoBehaviour {
public Vector3 pos;
// Use this for initialization
void Start () {
pos= transform.position;
Debug.Log("pos is " + pos);
}
}
Your answer
Follow this Question
Related Questions
Getting X/Y positions of the rotated Vector3 1 Answer
Remove object based on its position alone 1 Answer
Position in Vector (C#) 1 Answer
addition of vector3 1 Answer
2D get touch input 1 Answer