// Update is called once per frame void Update () { switch( m_State ) { case RotateByAngular05State.UnActive : break ; case RotateByAngular05State.InActive : Quaternion now = Quaternion.Lerp( this.transform.rotation , m_TargetRotation , m_AngleSpeed * Time.deltaTime ) ; this.transform.rotation = now ; if( Quaternion.Angle( this.transform.rotation , m_TargetRotation ) < 1.0f ) { this.transform.rotation = m_TargetRotation ; m_State = RotateByAngular05State.End ; } break ; case RotateByAngular05State.End : if( true == m_Suicide ) Component.Destroy( this ) ; break ; } }
// Use this for initialization void Start () { m_InitRotation = this.gameObject.transform.rotation ; m_TargetRotation = m_InitRotation * Quaternion.Euler( m_TargetAngle ) ; m_State = RotateByAngular05State.InActive ; }