0
這是我的腳本(用JavaScript編寫),它創建相機移動。我無法弄清楚如何做到這一點,以便我能讓它不會太靠近對象(目標)。這可能是簡單的事情,但我是Unity的小菜鳥。停止我的相機關閉
如果通過修改現有代碼無法獲得它,您能否提出另一種獲得所需運動的方法?
#pragma strict
var target : Transform;
var localOffset = Vector3(0,0,0);
var finalPos : Vector3;
var currentPos : Vector3;
var speed = 0.01;
private var startTime: float;
private var journeyLength: float;
function Start() {
startTime = Time.time;
}
function Update() {
currentPos = transform.position;
finalPos = target.position + (target.up * localOffset.z);
finalPos = target.position + (target.forward * localOffset.x);
transform.LookAt(target.position);
journeyLength = Vector3.Distance(transform.position, finalPos);
var distCovered = (Time.time - startTime) * speed;
var fracJourney = distCovered/journeyLength;
transform.position = Vector3.Lerp(transform.position, finalPos, fracJourney);
}
也許查找Unity的夾法......這可能是你是什麼 – Savlon
後,這不是JavaScript的,這是unityscript – LearnCocos2D