美文网首页
简单 unity 相机 跟随

简单 unity 相机 跟随

作者: 红定义 | 来源:发表于2017-03-07 08:03 被阅读0次

    using System.Collections;

    using System.Collections.Generic;

    using UnityEngine;

    public class ThirdPersonCameraFollow : MonoBehaviour

    {

    private Transform target;

    public float distanceUp = 10f;

    public float distanceAway = 15f;

    public float smooth = 2f;

    void Start()

    {

    target = GameObject.FindWithTag("Player").transform;

    }

    void LateUpdate()

    {

    Vector3 disPos = target.position + new Vector3(distanceAway, distanceUp, distanceAway);

    transform.position = disPos;// Vector3.Lerp(transform.position, disPos, Time.deltaTime * smooth);

    transform.LookAt(target.position);

    }

    }

    相关文章

      网友评论

          本文标题:简单 unity 相机 跟随

          本文链接:https://www.haomeiwen.com/subject/qdmpgttx.html