I´m creating (my first game) a word spelling game where the player drags 3D letters around to shape words to trigger events.
The only way I can think of doing this is by tagging and hard coding every word and letter. I have a collider for each letter and trigger destination that calls the ABCLetters script attached to theWordBoard.
It has to be many better ways of declaring when a specific word is spelled with the letters dragged into place. I´m thankful for any help. Below are my attempt.
The first word to type, ABC
using UnityEngine;
public class ABCLetters : MonoBehaviour {
public bool Option1 = false;
public bool Option2 = false;
public bool Option3 = false;
void Update()
{
if (Option1 == true && Option2 == true && Option3 == true)
{
Debug.Log("You did it!");
}
else if (Option1 == false && Option2 == false && Option3 == false)
{
Debug.Log("Try Again!");
}
}
}
Then for each letter I have made this script:
using UnityEngine;
public class LetterA : MonoBehaviour {
public GameObject theWordBoard;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "A")
{
Debug.Log("A");
theWordBoard.GetComponent<ABCLetters> (). Option1 = true;
}
}
}
Aucun commentaire:
Enregistrer un commentaire