one default and 2 random answers.
i want to make a scene where on start it shows you 3 options , one of these options will always appear and be right , the other two can switch between multiple wrong options the reason i want those randomized between multiple wrong options is so that u could play it more than once.
using UnityEngine; using System.Collections;
public class GamePlay : $$anonymous$$onoBehaviour { public int wAnswer = 0; private string wAnswerName = null; public GameObject[] FoodAnswer; public bool Correct;
// Use this for initialization
void Start()
{
FoodAnswer = GameObject.FindGameObjectsWithTag("Food");
Random.Range(1.0f, 5.0f);
}
void Display$$anonymous$$essage(string wAnswer)
{
Debug.Log("You chose the" + wAnswer + "!");
}
// Update is called once per frame
void On$$anonymous$$ouseDown()
{
if(Correct == true)
{
Destroy(this.gameObject);
}
if(Correct == false)
{
wrongAnswer(); // functie oproepen.
Debug.Log("please try again.");
}
}
void Update()
{
}
void wrongAnswer() // functie definitie.
{
wAnswer = Random.Range(1, 5);
switch (wAnswer)
{
/*case 1:
Debug.Log("You got the right answer!");
rAnswerName = "Herring";
Display$$anonymous$$essage(rAnswerName);
break;*/
case 2:
Debug.Log("That is not what a seal eats!");
wAnswerName = "Shrimp";
Display$$anonymous$$essage(wAnswerName);
break;
case 3:
Debug.Log("That is not what a seal eats!");
wAnswerName = "Crab";
Display$$anonymous$$essage(wAnswerName);
break;
case 4:
Debug.Log("That is not what a seal eats!");
wAnswerName = "Waffle";
Display$$anonymous$$essage(wAnswerName);
break;
default:
Debug.Log("What does a seal eat? please choose one!");
break;
}
}
}
This is what i have so far , i know cases are only for random options but i cant find a way to make 1 click always correct for a specific object.
Your answer
Follow this Question
Related Questions
Random colors? 0 Answers
Switch Case help 0 Answers
Switch Statement Gives Error PLEASE HELP!!! 2 Answers
Please explain a switch statement? 4 Answers
on and off music button in unity 5 0 Answers