我遇到了這個我不知道如何解決的問題,如果條件得到驗證,我有一個移動的物體會返回到一個位置,但它似乎有時在工作,但有時卻不是..這是我的腳本:using System.Collections;using System.Collections.Generic;using UnityEngine;public class MovingDes : MonoBehaviour { private float speed = 5f; Transform trn; //-37.6914 //62.32123 // Use this for initialization void Start() { trn = GetComponent<Transform>(); } // Update is called once per frame void Update() { transform.Translate(Vector3.back * (speed * Time.deltaTime)); if(transform.position.z <= -37.6914){ Vector3 newPosition = new Vector3(17.5f,125.7f,165.32123f); trn.position = newPosition; } }}問題是我可以在我的 Unity 編輯器中看到位置與我設置的不同,而且我不明白這些值來自哪里,我沒有肯定地寫它們。
- 2 回答
- 0 關注
- 846 瀏覽
添加回答
舉報
0/150
提交
取消
