Point one object to face a distant object

元气小坏坏 提交于 2019-12-11 13:52:06

问题


I have two objects, let's call them nearObject and farObject. Once nearObject gets within a certain distance from farObject, I want farObject to rotate to face nearObject. This should happen instantly, it does not need to slowly rotate over time.

1) The distance is arbitrary, so I am using the following to get distance information. nearObject.position.distanceToSquared(farObject.position);

2) Now I want farObject to rotate perpendicular to the vector between the two objects. What is the easiest way to do this?


回答1:


farObject.lookAt( nearObject.position );


来源:https://stackoverflow.com/questions/11440337/point-one-object-to-face-a-distant-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!