using UnityEngine;
using System.Collections;
public class FollowFarget : MonoBehaviour {
public Transform PlayerTransfrom;//定义一个公共组件,然后把主角拖到这个公共组件上,来获取主角的向量
private Vector3 Offset;
// Use this for initialization
void Start () {
Offset = transform.position - PlayerTransfrom.position;//两个向量相减
}
// Update is called once per frame
void Update () {
transform.position = PlayerTransfrom.position + Offset;//重新给相机的向量赋值
}
}
博客给出了一段Unity开发的代码,定义了一个名为FollowFarget的类,包含一个公共组件用于获取主角向量,还定义了一个私有向量Offset,主要涉及Unity开发中跟随目标的脚本实现。
626

被折叠的 条评论
为什么被折叠?



