using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/*by Alexander*/


//相机跟随脚本
public class CameraTracker : MonoBehaviour
{
    public Transform playerTransform;//跟踪的对象
    private Vector3 offset;


    void Start()
    {
        //         当前位置              物体的位置
        offset = transform.position - playerTransform.position;//计算相对距离
    }

    void Update()
    {
        transform.position = playerTransform.position + offset; //保持相对距离
    }
}


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-22
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
相关资源
相似解决方案