Im just wondering how i could go about doing this? i need to check if the created food is hitting my tail but then i cant do it in an normal OnCollisionEnter(collision : Collision) becuse then if the tail ever hits it it gets deleted, but say if it hit it only once it first is created then it would be swell?.. Could someone please help me
#pragma strict
var food : GameObject;
var sizeX = 20;
var sizeY = 20;
function OnCollisionEnter(collision : Collision)
{
if(collision.gameObject.tag == "Pillar")
{
Destroy (gameObject);
var position : Vector3 = Vector3(Random.Range(-sizeX, sizeX), 1.3, Random.Range(-sizeY, sizeY));
Instantiate(food, position, Quaternion.identity);
}
else if(collision.gameObject.tag == "edge")
{
Destroy (gameObject);
var position2 : Vector3 = Vector3(Random.Range(-sizeX, sizeX), 1.3, Random.Range(-sizeY, sizeY));
Instantiate(food, position2, Quaternion.identity);
}
else if(collision.gameObject.tag == "Tail")//this is the part that isent good
{
Destroy (gameObject);
var position2 : Vector3 = Vector3(Random.Range(-sizeX, sizeX), 1.3, Random.Range(-sizeY, sizeY));
Instantiate(food, position2, Quaternion.identity);
}
}