-1
我有一個剛體和一個球體的球員,我使用OnCollisionEnter
並希望使(球體/ objectB的球員/對象的父母),如果我使用腳本(其中標籤「GameController 「用於玩家和標籤」球體「用於球體)並且將該腳本附加到球體,球體成爲玩家的父母,但是當我將該腳本附加到玩家時,玩家不會成爲球體的父母。任何人都知道如何解決這個問題?使另一個對象的父對象
//script when attached to sphere
void OnCollisionEnter(Collision col) {
Debug.Log ("collision occur");
if(col.gameObject.tag=="player")
{
col.transform.parent=transform;
}
}
//script when attached to player
void OnCollisionEnter(Collision col) {
Debug.Log ("collision occur");
if(col.gameObject.tag=="sphere")
{
col.transform.parent=transform;
}
}
確保你進入這個'if(col.gameObject.tag ==「sphere」)' – FunctionR 2014-12-07 22:12:05