I’m making a game in which a person has to answer questions. I have this code which I have attached to many game objects-:
private var inRange: boolean = false;
var myStyle = new GUIStyle();
static var score:int;
public var mess: String = "Clue";
var stringToEdit : String = "Enter Here";
var finalstring:String="nil";
function OnTriggerEnter(other:Collider)
{
if (other.tag == "Player")
{
inRange = true;
}
}
function OnTriggerExit(other:Collider)
{
if (other.tag == "Player")
{
inRange = false;
}
if(score==5)
{
score=5;
}
}
function Update(){
if(finalstring==stringToEdit)
{
score=score+5;
stringToEdit="null";
}
}
function Start()
{
if(score==5)
{
score=5;
}
}
function OnGUI ()
{
if(inRange)
{
GUI.Label (Rect (10, 10, 100, 20),"Score: " +score.ToString());
// Make a text field that modifies stringToEdit.
stringToEdit = GUI.TextField (Rect (10, 50, 1000, 20), stringToEdit, 25);
GUI.Label (Rect (10, 30, 2000, 1000),"Clue: " +mess,myStyle);
}
}
The problem is that a person is able to answer a question many times, thus giving him more points. what can i do to make him answer only once