void CreateSnake(int blength) { Vector3 position; position.z = 0f; position.y = 0f; for (int i = 0; i < blength; i++) { GameObject Section; if (i < 2) { Section = Instantiate(HeadPrefab); if (i == 0) { Section.AddComponent <SnakeHead> (); } } else { Section = Instantiate(BodyPrefab); } position.x = -i * scale * 1f; Transform TSection = Section.GetComponent(typeof(Transform)) as Transform; TSection.localPosition = position; TSection.localScale = Vector3.one * scale; Snake.Add(Section); directions.Enqueue("R"); } }