Skip to content

Instantly share code, notes, and snippets.

@tarukosu
Created November 19, 2017 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarukosu/8440c1a79e94d593482ab85f53289e9e to your computer and use it in GitHub Desktop.
Save tarukosu/8440c1a79e94d593482ab85f53289e9e to your computer and use it in GitHub Desktop.
RotationPlayableBehaviour.cs
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