我想统一旋转球体上的播放器,并使用此代码旋转球体,但它可以在球体上的某些位置工作,有人可以帮助解决此问题吗?或click链接以观看有问题的视频。
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class Follow_guide_pos : MonoBehaviour {
private Vector3 input;
void Update () {
//rotation of player input
input = new Vector3(CrossPlatformInputManager.GetAxisRaw("Horizontal_rot"),CrossPlatformInputManager.GetAxisRaw("Vertical_rot"),0);
}
void FixedUpdate(){
//rotation of player output
transform.LookAt(transform.position+input,transform.up);
}
}
Link to the video是问题的视频。 0:03-0:07飞机正确旋转 但沿其他方向移动后,它会沿不同的轴旋转,或者不像以前那样旋转。
答案 0 :(得分:0)
The LookAt function takes an "up" direction to help it align the object in the desired orientation. As you move around the sphere, the true "up" of your vehicle is changing. So you need to change the the "up" vector in LookAt to match the desired "up" of your vehicle.