物体旋转到指定角度
public float Speed;
Quaternion targetAngels;
public GameObject gam;
// Use this for initialization
void Start () {
targetAngels = Quaternion.Euler(90, 0, 0);
}
private void OnTriggerStay(Collider other)
{
if (other.gameObject.name == "Sphere")
{
//速度随旋转角度的接近减慢
this.gameObject.transform.rotation = Quaternion.Slerp(transform.rotation, targetAngels, Speed * Time.deltaTime);
//速度恒定旋转
this.gameObject.transform.rotation = Quaternion.RotateTowards(transform.rotation, targetAngels, Speed * Time.deltaTime);
}
}