using System.Collections; using System.Collections.Generic; using UnityEngine; public class otherWoniu : MonoBehaviour { public Transform OrPosTrams;//出发点 public Transform Panrent;//父亲节点 //public AllHouseContro allHouseContros; // Start is called before the first frame update void Start() { //OtherWoniuMove(); //allHouseContros=GameObject.Find("Canvas/Bg").GetComponent(); } public void OtherWoniuMove(HouseBtn house) { transform.GetComponent().EndPos=house.post.transform; transform.GetComponent().StartMove(); } public void BackWait() { // 需要时将 childObject 移回原始父物体,并设置为第一个子节点 transform.SetParent(Panrent); Vector3 RePos = Panrent.position; RePos = new Vector2(RePos.x + Random.Range(-300, 300), RePos.y + Random.Range(-80, 80)); transform.position = RePos; transform.GetComponent().StartPos = OrPosTrams; //transform.position =new Vector2 (Random.Range(-50,50), Random.Range(-50, 50)); } }