Hi
i am making game for kids to collect given letters to complete a word with correct order, they drag and drop the letter in the correct place to give them correct or false sound.This is a screen shot and the code for the GameObject (where the player should place the letter) in the scene with just different names of variables of each different GameObject
using UnityEngine;
using System.Collections;
public class GameTrigger2_1 : MonoBehaviour {
public AudioClip R;
public AudioClip W;
public bool isCorrect=false;
public static GameTrigger2_1 Instancei;
private GameTrigger2_1()
{
Instancei = this;
}
//
public void OnTriggerEnter2D(Collider2D collisionObject){
if (string.Equals (collisionObject.tag, "i2")) {
audio.PlayOneShot (R);
isCorrect = true;
Debug.Log (isCorrect);
} else
audio.PlayOneShot (W);
}
}
if the player placed all the correct letters in the correct order, GameManager object will execute its code :
void Update () {
if (GameTrigger2_1.Instancei.isCorrect && GameTrigger2_2.Instancec.isCorrect
&& GameTrigger2_3.Instancee.isCorrect && GameTrigger2_4.Instancec.isCorrect
&& GameTrigger2_5.Instancer.isCorrect && GameTrigger2_6.Instancee.isCorrect
&& GameTrigger2_7.Instancea.isCorrect && GameTrigger2_8.Instancem.isCorrect)
Application.LoadLevel ("Victory2");
}
everything works fine but the problem in my code when i put the letter in the correct place , isCorrect boolean will be true, and if i removed the leter from that place it will stay true, for example , if i want to collect word icecream , if i placed letter ‘i’ in the correct place and remove it , isCorrect will stay true, i want it to return false if i removed it from the correct order and not stuck to true value.
What should i do ? please URGENT Help