I’m currently making a game using Unity for an EAST project and my way of making it school ready is by making the game prompt the player with a grammatical question when they try opening a door with a key. I like this idea in theory, but I personally don’t know how to accomplish this in Unity. For example, when the player walks up to a door with a key in their inventory and try to open the door, I want it to prompt the player with the text “I heard that there food is great, we should eat that instead.” Then, it will ask the question “Correct this sentence.” The player will then be prompted with the interface showing “________ needs to be changed to ________” The user will then be able to input “there” “their”, thus filling the blanks with the answer. Upon doing this, the door should open for the player and allow them to go inside. I’m not fully sure if this function is even possible to do in Unity, but it’s hypothetically a key feature for my project and any help with this issue would be greatly appreciated. Also it’s any help, this is the code that I currently have in my game for the doors to be opened (the code is written in Java):
var smooth = 2.0;
var DoorOpenAngle = 90.0;
private var open : boolean;
private var enter : boolean;
private var defaultRot : Vector3;
private var openRot : Vector3;
function Start(){
defaultRot = transform.eulerAngles;
openRot = new Vector3 (defaultRot.x, defaultRot.y + DoorOpenAngle, defaultRot.z);
}
//Main function
function Update (){
if(open){
//Open door
transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, openRot, Time.deltaTime * smooth);
}else{
//Close door
transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, defaultRot, Time.deltaTime * smooth);
}
if(Input.GetKeyDown("q") && enter){
open = !open;
}
}
function OnGUI(){
if(enter){
GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 150, 30), "Press 'Q' to open the door");
}
}
//Activate the Main function when player is near the door
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player") {
enter = true;
}
}
//Deactivate the Main function when player is go away from door
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player") {
enter = false;
}
}