21 lines
542 B
C#
21 lines
542 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CameraFollower : MonoBehaviour
|
|
{
|
|
public Transform target;
|
|
public float smoothness =0.1f;
|
|
public Vector3 offset;
|
|
void Start()
|
|
{
|
|
// offset= transform.position - target.position;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void FixedUpdate()
|
|
{
|
|
transform.position = Vector3.Lerp(transform.position, new Vector3(target.position.x - offset.x, transform.position.y, transform.position.z), smoothness);
|
|
}
|
|
}
|