【问题标题】:Why is my gameobject moving to the wrong place?为什么我的游戏对象移动到错误的位置?
【发布时间】:2016-06-13 14:22:22
【问题描述】:

我将以下脚本附加到我想控制提升 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);
        }
    }

【问题讨论】:

    标签: c# unity3d


    【解决方案1】:

    我希望正确理解您的问题:但您不想执行以下操作吗?

    Vector3.MoveTowards(hoist.transform.position, target.position, step);
    

    因此,将起重物体移向目标位置。抱歉,如果我误解了请求。

    【讨论】:

    • 你是对的。不敢相信我错过了。感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多