Created
October 10, 2015 20:38
-
-
Save fiskefyren/ebf47956318bf4444cf2 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 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