You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
586 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DynamicCamera : MonoBehaviour
{
public GameObject target;
public float camHeight;
void Start()
{
}
void Follow()
{
Vector3 tempDest = target.transform.position;
tempDest -= transform.forward * camHeight;
Vector3 destination = Vector3.Lerp(transform.position, tempDest, 10f * Time.deltaTime);
transform.position = destination;
}
// Update is called once per frame
void FixedUpdate()
{
Follow();
}
}