![](/img/trans.png)
[英]Why are BoxCollider and GameObject moving to the wrong place?
[英]Why is my gameobject moving to the wrong place?
我將以下腳本附加到要控制提升機GO的GO上。 葫蘆應該移動到目標位置,但是最后移動到我必須附加到腳本上的GO。 是什么原因造成的,我該如何解決?
using UnityEngine;
using System.Collections;
public class HoistTest : MonoBehaviour
{
public GameObject hoist;
public Transform target;
public float speed;
void OnMouseUp()
{
float step = speed * Time.deltaTime;
hoist.transform.position = Vector3.MoveTowards(transform.position, target.position, step);
}
}
我希望正確理解您的問題:但是您不想執行以下操作嗎?
Vector3.MoveTowards(hoist.transform.position, target.position, step);
因此,將提升對象移向目標位置。 抱歉,如果我誤解了請求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.