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