标签:
1 using UnityEngine; 2 using System.Collections; 3 /* 4 * 摄像机跟随 第三人称常用方式 5 */ 6 public class CameraCS : MonoBehaviour { 7 8 private Transform player; 9 private Vector3 offsetPosition; 10 // Use this for initialization 11 12 void Awake(){ 13 player = GameObject.FindGameObjectWithTag ("Player").transform; 14 } 15 16 void Start () { 17 //摄像机朝向player 18 transform.LookAt (player.position); 19 //获取摄像机与player的位置偏移 20 offsetPosition = transform.position - player.position; 21 } 22 23 // Update is called once per frame 24 void Update () { 25 //摄像机跟随player与player保持相对位置偏移 26 transform.position = offsetPosition + player.position; 27 } 28 }
标签:
原文地址:http://www.cnblogs.com/yuge790615/p/5580178.html