Guest User

Untitled

a guest
Nov 20th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.Playables;
  3.  
  4. public class PositionPlayableBehaviour : PlayableBehaviour
  5. {
  6. public GameObject targetObject;
  7. public Vector3 startPosition;
  8. public Vector3 endPosition;
  9.  
  10. public override void ProcessFrame(Playable playable, FrameData info, object playerData)
  11. {
  12. if (targetObject == null)
  13. {
  14. return;
  15. }
  16. var t = (float)playable.GetTime() / (float)playable.GetDuration();
  17. float leapt = (t * t) * (3f - (2f * t));
  18. targetObject.transform.localPosition = Vector3.Lerp(startPosition, endPosition, Mathf.Clamp01(leapt));
  19. }
  20. }
Add Comment
Please, Sign In to add comment