using System.Collections; using System.Collections.Generic; using UnityEngine; public class AutoA : MonoBehaviour { GameObject LuoGan04; Vector3 LuoGan04Aim = new Vector3(37.71f, 4.74f, -22.0f); Quaternion LuoGan04Qua = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f); // Use this for initialization void Start() { LuoGan04 = GameObject.Find("04_LuoGan"); print(LuoGan04.name); } // Update is called once per frame void Update() { print("000000000p" + LuoGan04.transform.localPosition); print("1111111111111p" + LuoGan04Aim); print("2222222222222p" + (LuoGan04.transform.localPosition - LuoGan04Aim).magnitude); if (Mathf.Sqrt((LuoGan04.transform.localPosition - LuoGan04Aim).magnitude) < 1.5) { LuoGan04.transform.localPosition = LuoGan04Aim; LuoGan04.transform.localRotation = LuoGan04Qua; } } }