Created
November 19, 2017 13:56
-
-
Save tarukosu/8440c1a79e94d593482ab85f53289e9e to your computer and use it in GitHub Desktop.
RotationPlayableBehaviour.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.Playables; | |
public class RotationPlayableBehaviour : PlayableBehaviour | |
{ | |
public GameObject targetObject; | |
public Quaternion startRotation; | |
public Quaternion endRotation; | |
public override void ProcessFrame(Playable playable, FrameData info, object playerData) | |
{ | |
if (targetObject == null) | |
{ | |
return; | |
} | |
var t = (float)playable.GetTime() / (float)playable.GetDuration(); | |
float leapt = (t * t) * (3f - (2f * t)); | |
targetObject.transform.localRotation = Quaternion.Lerp(startRotation, endRotation, Mathf.Clamp01(leapt)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment