-1
我想在碰撞時使用另一3D對象拖動3D對象。任何人都可以幫我如何在統一中使用腳本將3D對象與另一個3d對象進行拖動?
我想在碰撞時使用另一3D對象拖動3D對象。任何人都可以幫我如何在統一中使用腳本將3D對象與另一個3d對象進行拖動?
我假設通過「拖動」你的意思是在某些條件下跟隨其他對象的對象。
你應該使用Vector3.MoveTowards()女巫將對象移動一個對象。
// The target marker.
var target: Transform;
// Speed in units per sec.
var speed: float;
function Update() {
// The step size is equal to speed times frame time.
var step = speed * Time.deltaTime;
// Move our position a step closer to the target.
transform.position = Vector3.MoveTowards(transform.position, target.position, step);
}
從統一的文檔: https://docs.unity3d.com/ScriptReference/Vector3.MoveTowards.html