欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

using UnityEngine;
using System.Collections;
 
public class FllowTarget : MonoBehaviour {
 
  public Transform character;  //攝像機要跟隨的人物
  public float smoothTime = 0.01f; //攝像機平滑移動的時間
  private Vector3 cameraVelocity = Vector3.zero;
  private Camera mainCamera; //主攝像機(有時候會在工程中有多個攝像機,但是只能有一個主攝像機吧)
  
  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習unity有所幫助。

相關(guān)文章

最新評論