So i am making a snake game, that, when the character gets the food, creates an instantiation from a prefab. However, this instance remains on top of my character, and moves along with it, but only inside. How do i get it to move back to behind the main character, and then follow it. The instantiate code is:
function OnCollisionEnter(collision : Collision)
{
if(collision.gameObject.tag == "Player")
{
Destroy(gameObject);
Instantiate(BodyPrefab, GameObject.Find("Snake").transform.position, Quaternion.identity);
BodyPrefab.Instantiate.transform.parent = ("Snake").transform;
//not sure if this how to parent it
}
}
I’m not sure what to do, i imagine that at the moment of instantiation, move it back so many squares…
Thanks, guys! =]