//位置修改
player.transform.position = new Vector3( Camera.main.transform.position.x, Camera.main.transform.position.y+3);
player.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0,0);
player.transform.localRotation = Quaternion.Euler(0,0,0);
//對象、子對象、孫子對象的獲取
GameObject Obj = GameObject.Find ("對象名"); //用於找hierarchy下的第一層對象
Transform[] AllChildrenRTran = parent.transform.GetComponentInChildren();//用來找多個對象或者不知道具體名字的對象
foreach(Transform childTran in AllChildrenTran) {
GameObject childObj = childTran.gameObject;
}
//知道parent對象的子對象的子對象名字叫 name2 ,就可以這樣直截了當的獲取了,就是這樣毫無人性,注意沒有雙引號
parent.transform.FindChild(name1/name2).gameObject;
//獲取組件、組件屬性
Vector2D speed = player.GetComponent<Rigidbody2D> ().velocity; //還是這個例子,獲得剛體的速度
//腳本獲取游戲對象
腳本文件類對象.transform.gameobject
//腳本文件獲取被綁定對象的子對象,這個方法也是讓人耳目一新
腳本文件類對象.transform.GetChild(i) //i是指第幾個子對象,子對象個數用 -> 腳本文件類對象.transform.childCount <- 表示