23 lines
796 B
C#
23 lines
796 B
C#
using UnityEngine;
|
|
using System;
|
|
|
|
public class RotateToZ : SomethingTo {
|
|
|
|
private Quaternion fromQuaternion;
|
|
private float targetAngle;
|
|
|
|
private void Lerp(float lerp){
|
|
transform.rotation = fromQuaternion * Quaternion.AngleAxis(Mathf.Lerp(0.0f, targetAngle, lerp), Vector3.forward);
|
|
}
|
|
|
|
public void ChangeRotation(float targetAngle, float interval, EasingType easingType = EasingType.Linear){
|
|
ChangeRotation(targetAngle, interval, ActionExtensions.EmptyAction, easingType);
|
|
}
|
|
|
|
public void ChangeRotation(float targetAngle, float interval, Action callback, EasingType easingType = EasingType.Linear){
|
|
this.targetAngle = targetAngle;
|
|
this.fromQuaternion = transform.rotation;
|
|
Begin(Lerp, interval, callback, easingType);
|
|
}
|
|
}
|