void OnCollisionEnter2D(Collision2D coll) { //If the player is invulnerable we immediately destroy the robot on contact. //If the player is not invulnerable then we present them with a quiz! if (isPlayerInvulnerable == true) { destroyObject(); } else if (QuizNumber < 1 ) { QuizNumber++; //If the character collides and is not invulnerable if (coll.collider.name == characterName && (isPlayerInvulnerable == false) ) { Movement.ToggleMovement (); //Create one quiz Quiz newQuiz = new Quiz (1); //Get the currentQuestion Question currentQuestion = newQuiz.getCurrentQuestion (); //create a quiz window with the new data to display QuizWindow quizWindow = gameObject.AddComponent<QuizWindow> (); quizWindow.CreateWindow (currentQuestion); //show the window after all the data is assigned quizWindow.ShowWindow (); //print("Current Question :" + currentQuestion.getQuestionString()); //print("Get Answers : " + currentQuestion.getAnwsers()); //print("Correct Answer : "+ currentQuestion.correctAnwser); } } }