I have a player with rigid body and a sphere am using OnCollisionEnter and want to make (player/objectA parent of sphere/objectB) , if i use the script (where tag “GameController is for player and tag"sphere” is for sphere) and attached this script to sphere the sphere becomes parent of player but when i attach this script to player, player would not becomes the parrent of sphere. Any one know how to solve this problem?
//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;
}
}