Created
May 1, 2019 16:44
-
-
Save emilianavt/276ae15a3fb32964863e28bdfd246594 to your computer and use it in GitHub Desktop.
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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class TrackerLerp : MonoBehaviour { | |
public Transform target; | |
public float targetFPS = 90.0f; | |
public float influence = 0.985f; | |
void LateUpdate () { | |
float timeScale = 1.0f / targetFPS; | |
float factor = influence * (Time.deltaTime / timeScale); | |
transform.position = Vector3.Lerp(transform.position, target.position, factor); | |
transform.localScale = Vector3.Lerp(transform.localScale, target.localScale, factor); | |
transform.rotation = Quaternion.Slerp(transform.rotation, target.rotation, factor); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment