Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraFollow : MonoBehaviour
- {
- public Transform m_Target;
- public float m_offsetHeight = 7;
- public float m_offsetDistance = 12;
- public float m_lerpTime = 0.4f;
- // Use this for initialization
- private void Start ()
- {
- if (m_Target == null)
- {
- Debug.LogError("CameraFollow: Missing Target!");
- }
- }
- private void FixedUpdate()
- {
- if (m_Target != null)
- {
- Vector3 offset = m_Target.forward * -m_offsetDistance + (Vector3.up * m_offsetHeight);
- transform.position = Vector3.Lerp(transform.position, m_Target.position + offset, m_lerpTime * Time.deltaTime);
- transform.LookAt(m_Target);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement