void Update () {
        if (inRotation){
            Quaternion rotation = Quaternion.LookRotation(target.position - this.transform.position);
            float t = Mathf.Min(Time.deltaTime * 2,1);
            rotation = Quaternion.Lerp(transform.rotation, rotation, t);
            this.transform.rotation = rotation;
            if (t==1){
                inRotation = false;
            }
        }
    }
    
    void OnGUI(){
        if (GUI.Button(new Rect(0,0,150,40),"transform.LookAt")){
            this.transform.LookAt(target.position);
        }
        if (GUI.Button(new Rect(0,50,150,40),"transform.rotation")){
            inRotation = true;
            //this.transform.rotation = Quaternion.LookRotation(target.position - this.transform.position);
            
        }
    }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2021-07-04
  • 2021-09-09
猜你喜欢
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案