ThirdPersonCamera

来源:互联网 发布:淘宝网苏泊尔砂锅内胆 编辑:程序博客网 时间:2024/05/17 22:28
using UnityEngine;
using System.Collections;


public class ThirdPersonCamera : MonoBehaviour
{
public float distanceAway;
public float distanceUp;
public float smooth;

private Vector3 targetPosition;

Transform follow;

void Start(){
follow = GameObject.FindWithTag ("Player").transform;
}

void LateUpdate ()
{
targetPosition = follow.position + Vector3.up * distanceUp - follow.forward * distanceAway;

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

transform.LookAt(follow);
}
}
0 0
原创粉丝点击