I have a collider with an object that, when my character hits it, creates an instantiated cube. What i want this cube to do is fall directly behind the players cube, and then follow it around. Yes this is a snake game. I’m not worrying about getting it move in blocks yet, that will follow. I just need to know how to parent it. Here is the instantiation code:
var BodyPrefab : Transform; //set in inspector with my prefab
function OnTriggerEnter(other : Collider)
{
if(other.gameObject.tag == "Player")
{
print ("FOOD!");
Instantiate(BodyPrefab, GameObject.Find("Snake").transform.position, Quaternion.identity);
BodyPrefab.transform.parent = gameObject.transform;
Destroy(gameObject);
}
}
Thanks guys.