unity 3D获取当前物体得坐标
与物体绑定好:
public class location : MonoBehaviour
{
// Start is called before the first frame update
public GameObject A;
public Vector3 localPosition;
void Start()
{
}
// Update is called once per frame
void Update()
{
print("位置坐标" + this.transform.localPosition);
print("X坐标为:" + this.transform.localPosition.x);
}
}
这样就可以实时获取当前物体坐标。