我试图得到从游戏对象的BoxCollider中心到同一个BoxCollider的底部的距离。注意,对撞机的中心是轻巧修改的。
到目前为止,我已经:
float halfHeightCollider = (bounds.size.y / 2);
我尝试了以下几点来处理轻微的修改:
float halfHeightCollider = bounds.center.y + (bounds.size.y / 2);
但是bounds.center
似乎给出了BoxCollider中心在世界上的位置,而不是相对于游戏对象的位置,比如在检查员中:
那个价值就是我想要的。我怎么才能拿到呢?
发布于 2016-06-29 17:00:25
你可以从gameObject.GetComponent<BoxCollider>().center.y
得到y轴的中心.
你将从gameObject.GetComponent<BoxCollider>().size.y
得到对撞机y轴的总尺寸.
然后取y-size/2,减去y-轴的中心值。
https://gamedev.stackexchange.com/questions/124676
复制相似问题