dwelling acts 1 & 3
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.

35 lines
1002 B

1 year ago
using UnityEngine;
1 year ago
1 year ago
public class CameraFollow : MonoBehaviour
{
[Tooltip("The target to follow")] public Transform target;
[Tooltip("The time it takes to move to the new position")]
public float smoothingTime; //The time it takes to move to the new position
private Vector3 m_Offset;
1 year ago
public float m_Div = 10f;
1 year ago
private Vector3 m_CamVelocity; //Camera's velocity (used by SmoothDamp)
// Use this for initialization
void Start()
{
m_Offset = gameObject.transform.position - target.position;
}
void FixedUpdate()
{
1 year ago
var newPosition = new Vector3(transform.position.x, target.position.y + m_Offset.y,
transform.position.z);
1 year ago
gameObject.transform.position =
Vector3.SmoothDamp(transform.position, newPosition, ref m_CamVelocity, smoothingTime, Mathf.Infinity,
Time.fixedDeltaTime);
}
}