[英]A point in 3D space from an angle
I'm currently working on a camera for a game.我目前正在为游戏制作相机。 But I got stuck at the rotation.
但是我卡在了轮换上。
When I move my mouse across the x- or y-axis, I want the camera to rotate around my character.当我在 x 或 y 轴上移动鼠标时,我希望相机围绕我的角色旋转。
What would be a formula to calculate this vector, if the distance to the character is always the same?如果到字符的距离始终相同,那么计算这个向量的公式是什么?
I am doing this in Unity, with C#, if this is of any help.我在 Unity 中使用 C# 执行此操作,如果这有帮助的话。
this function may help: transform.RotateAround(Vector3 axis, float degree)
you can read the Unity Script Reference for more info.这个 function 可能会有所帮助:
transform.RotateAround(Vector3 axis, float degree)
您可以阅读 Unity 脚本参考以获取更多信息。
-oh and I think you should tag your next questions with "unity3d" but you get the best Unity3d-help at UnityAnswers-Forum http://answers.unity3d.com/index.html . -哦,我认为您应该用“unity3d”标记您的下一个问题,但是您可以在 UnityAnswers-Forum http://answers.unity3d.com/index.ZFC35FZ30D5FC69D29E8.826获得最好的 Unity3d 帮助
You can utilise spherical coordinates — they seem to fit more than Euler angles for the purpose of camera movement.您可以使用球坐标——它们似乎比欧拉角更适合相机移动。 The Cartesian vector which you need can be obtained by simple formulas as described there.
您需要的笛卡尔向量可以通过那里描述的简单公式获得。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.