Guest User

TrackerLerp

a guest
May 24th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class TrackerLerp : MonoBehaviour {
  6.     public Transform target;
  7.     public float targetFPS = 90.0f;
  8.     public float influence = 0.985f;
  9.  
  10.     void LateUpdate () {
  11.         float timeScale = 1.0f / targetFPS;
  12.         float factor = influence * (Time.deltaTime / timeScale);
  13.         transform.position = Vector3.Lerp(transform.position, target.position, factor);
  14.         transform.localScale = Vector3.Lerp(transform.localScale, target.localScale, factor);
  15.         transform.rotation = Quaternion.Slerp(transform.rotation, target.rotation, factor);
  16.     }
  17. }
Add Comment
Please, Sign In to add comment