I have solved the old problems, now got new problem. Every thing is working fine except new snake, when the first snake dead the new snake is creating but its not performing like the old snake.I tried to figure out the problem, i got to know that the problem is when ever the new snake got created the Snake script(CHECK BOX) in the inspector is getting unchecked, if I tick that check box the snake is working fine otherwise its not working. One more problem is that i SmooothFollow camera is not following the new snake.
var speed = 5.0;
var food : Transform;
var snake : Transform;
function Update ()
{
var x = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
var z = Input.GetAxis("Vertical") * Time.deltaTime * speed;
transform.Translate(x, 0, z);
}
function OnCollisionEnter(theCollision : Collision)
{
if(theCollision.gameObject.tag == "Food")
{
Debug.Log("Hit the Food");
Destroy(theCollision.gameObject);
var position = Vector3(Random.Range(-3,10), 0.284 ,Random.Range(-10, 10));
Instantiate(food, position, Quaternion.identity);
}
else
if(theCollision.gameObject.tag == "Wall"){
Debug.Log("Snake hit the wall");
Destroy(gameObject);
Debug.Log("Snake dead");
Instantiate(snake, Vector3(Random.Range(-3,10), 0.375 ,Random.Range(-9, 9)), Quaternion.identity);
Debug.Log("Camera for the Snake");
gameObject.Find("Main Camera").transform.position = Vector3(0,7,-15);
Debug.Log("Got new Camera for the Snake");
}
}
Can any one help me out in solving this problem..........