首页 > 编程语言 > 详细

unity 获取和设置gameObject的坐标

时间:2014-10-10 22:23:06      阅读:443      评论:0      收藏:0      [点我收藏+]

// 获取player_postion变量指定的对象的三围坐标

Vector3 player_postion = Player.transform.position;

 

// 获取X,Y,Z值

 float x = player_postion.x;

 float y = player_postion.y;

 float z = player_postion.z;

 

// 设置应用了当前函数的GameObject的坐标

// 1.直接赋值

this.GetComponent<Transform>().position = player_postion;

// 2.在某GameObject的基础上加

this.GetComponent<Transform>().position = new Vector3(player_postion.x, player_postion.y + 7.79F, player_postion.z - 15);

//或者是

this.GetComponent<Transform>().position = player_postion + new Vector3(0, 7.79F, -15);

 

unity 获取和设置gameObject的坐标

原文:http://www.cnblogs.com/Kprogram/p/4017811.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!