Skip to content

Instantly share code, notes, and snippets.

@emilianavt
Created May 1, 2019 16:44
Show Gist options
  • Save emilianavt/276ae15a3fb32964863e28bdfd246594 to your computer and use it in GitHub Desktop.
Save emilianavt/276ae15a3fb32964863e28bdfd246594 to your computer and use it in GitHub Desktop.
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