亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

unity實(shí)現(xiàn)攝像頭跟隨

 更新時(shí)間:2015年03月30日 11:48:31   投稿:hebedich  
把這個(gè)腳本賦給你的攝像機(jī),再把游戲角色賦給character變量,之后就能實(shí)現(xiàn)攝像機(jī)平滑的跟隨player在地球的任一角落了。有需要的小伙伴可以參考下。

代碼很簡單,這里就不多廢話了,直接奉上代碼

using UnityEngine;
using System.Collections;
 
public class FllowTarget : MonoBehaviour {
 
  public Transform character;  //攝像機(jī)要跟隨的人物
  public float smoothTime = 0.01f; //攝像機(jī)平滑移動(dòng)的時(shí)間
  private Vector3 cameraVelocity = Vector3.zero;
  private Camera mainCamera; //主攝像機(jī)(有時(shí)候會(huì)在工程中有多個(gè)攝像機(jī),但是只能有一個(gè)主攝像機(jī)吧)
  
  void Awake () 
  { 
   mainCamera = Camera.main;
  }
 
  void Update()
  {
    transform.position = Vector3.SmoothDamp(transform.position, character.position + new Vector3(0, 0, -5), ref cameraVelocity, smoothTime);
  }
  
}

以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡,能夠?qū)Υ蠹覍W(xué)習(xí)unity有所幫助。

相關(guān)文章

最新評(píng)論