Skip to content

Instantly share code, notes, and snippets.

@tarukosu
Created November 19, 2017 13:57
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/d0daa77efb37b4c07aac5321e8caf44a to your computer and use it in GitHub Desktop.
Save tarukosu/d0daa77efb37b4c07aac5321e8caf44a to your computer and use it in GitHub Desktop.
ScalePlayableBehaviour.cs
using UnityEngine;
using UnityEngine.Playables;
public class ScalePlayableBehaviour : PlayableBehaviour
{
public GameObject targetObject;
public Vector3 startScale;
public Vector3 endScale;
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.localScale = Vector3.Lerp(startScale, endScale, Mathf.Clamp01(leapt));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment