【发布时间】:2019-08-29 15:10:19
【问题描述】:
我有这个层次结构:
ScriptHandler <= this have script
MultiShape <= taking sides[] from here
local_axis_1 <= I need Global coordinates of this
local_axis_2 <= side[i] have this as GameObject field
Projectile1
Projectile2
我需要 TransformPoint,以获取全局坐标中 localAxises 的位置。但是,我试图做的一切都失败了:检查代码。
那么如何获取这个游戏对象的全局位置呢?
有些人建议这样做:sides[i].transform.parent.TransformPoint(sides[i].transform.position)
这个东西效果很好,然后MultiShape有旋转(0,0,0)。但后来我改变了 z 的旋转,它不起作用。
//this dont work anytime, even rotation is 0,0,0
ShapeSide[] sides = mainMesh.shapeSides;
Vector3 pos = sides[i].localAxis.transform.TransformPoint(sides[i].localAxis.transform.position);
//this works only then rotation is 0,0,0
ShapeSide[] sides = mainMesh.shapeSides;
Vector3 pos = sides[i].localAxis.transform.parent.TransformPoint(sides[i].localAxis.transform.position);
【问题讨论】:
-
transform.position已经是全球定位。 -
@Draco18s 哈哈,它真的很管用.....发送答案,我选择它