Unity基础学习,摄像机移动脚本

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

public class CameraMove : MonoBehaviour
{
    
    
    public float zOffset = 4;

    public float yOffset = 7;
     
    public Transform target;
    // Start is called before the first frame update
    void Start()
    {
    
    
        
    }

    // Update is called once per frame
    void Update()
    {
    
    
        
    }

    private void LateUpdate()
    {
    
    
        //摄像机的位置,等于目标的位置,进行向量偏移
        this.transform.position = target.position + -target.forward * zOffset + target.up * yOffset;

        this.transform.LookAt(target);
    }
}

摄像机移动脚本

猜你喜欢

转载自blog.csdn.net/charlsdm/article/details/126977127