Created
April 14, 2018 00:14
-
-
Save momo-the-monster/11e092db552d16beb881bd21c226040e 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 AudienceCamera : MonoBehaviour | |
{ | |
public GameObject mainCameraEye; | |
public bool lockZ = true; | |
[Range(10f,0.5f)] | |
public float positionLag = 3.0f; | |
[Range(10f, 0.5f)] | |
public float rotationLag = 2.0f; | |
void LateUpdate() | |
{ | |
Quaternion targetRot; | |
Vector3 eulerRot = mainCameraEye.transform.localRotation.eulerAngles; | |
if (lockZ) | |
{ | |
eulerRot.z = 0.0f; | |
} | |
targetRot = Quaternion.Euler(eulerRot); | |
transform.localPosition = Vector3.Slerp(transform.localPosition, mainCameraEye.transform.localPosition, positionLag * Time.unscaledDeltaTime); | |
transform.localRotation = Quaternion.Slerp(transform.localRotation, targetRot, rotationLag * Time.unscaledDeltaTime); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment