using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour {
public Transform target; // 这个可以直接拖拽 (player)
public float smoothing = 5f;
Vector3 offset;
void Start()
{
offset = transform.position - target.position;
}
void FixedUpdate()
{
Vector3 targetCamPos = target.position + offset;
// Time.deltaTime 上一帧所用的时间
transform.position = Vector3.Lerp(transform.position,targetCamPos,
smoothing * Time.deltaTime);
}
}
Unity3d 二维Camera跟随(摄像机缓动)
最新推荐文章于 2024-06-24 12:15:53 发布