物体旋转到指定角度

 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);
        }
    }

相关文章:

  • 2022-12-23
  • 2022-02-09
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
猜你喜欢
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案