Skip to content

Instantly share code, notes, and snippets.

@fiskefyren
Created October 10, 2015 20:38
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 fiskefyren/ebf47956318bf4444cf2 to your computer and use it in GitHub Desktop.
Save fiskefyren/ebf47956318bf4444cf2 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class SmoothCamFollow : MonoBehaviour {
public GameObject target;
public float smooth;
public Vector3 position;
public Quaternion rotation;
void FixedUpdate () {
Vector3 tempPos = target.transform.position + position;
Quaternion tempRot = target.transform.rotation + rotation; //not sure why this doesn't work D:
transform.position = Vector3.Lerp(transform.position, tempPos, Time.deltaTime * smooth);
transform.rotation = Quaternion.Slerp(transform.rotation, tempRot, Time.deltaTime * smooth);
transform.LookAt(target.transform);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment