Away3D (4.x broomstick) 如何将对象的全局位置转换为局部位置?
我正在构建一个向目标(平面)发射球的游戏。飞机向后旋转 45 度。我想将全局球位置(x,y,z)转换为目标的本地坐标,以便我可以检测它击中的位置。
有什么想法吗?
I am building a game that launches a ball at a target(Plane). The Plane is rotated back 45 degrees. I want to convert the global ball position(x,y,z) into the local coords of the target so I can detect where it hits.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用目标平面的
inverseSceneTransform
来变换球的position
向量。应该可以做到这一点。这应该可以告诉你球在飞机局部空间中的位置。
Use the target plane's
inverseSceneTransform
to transform theposition
vector of the ball. That should do it.That should give you the ball's position in the plane's local space.
上述解决方案仅在物品/球直接位于舞台上时才有效。如果不是,您应该使用 ball.scenePosition!
Above solution only works if the item/ball is directly on the stage. If it isnt, you should use ball.scenePosition!