Quantcast
Channel: Latest Questions by GraviterX
Viewing all articles
Browse latest Browse all 122

Check GUI Text Field

$
0
0
So I have this script where the Player can type text, hit enter, and an AI responds to it depending what the text is. However, the if statement that's supposed to check if the text is a greeting isn't working, and regardless of what the text is, the AI responds with a greeting. Any help on how to fix this? var stringToEdit : String = "Hello World"; private var aiResponse : String = " "; var basicGreetings : String []; function OnGUI () { stringToEdit = GUI.TextField (Rect (320, 145, 200, 20), stringToEdit, 25); GUI.Box(Rect(0,0,Screen.width,Screen.height), aiResponse); } function Update() { if(Input.GetKeyDown (KeyCode.Return)) { if(stringToEdit == "Hello"); { aiResponse = basicGreetings[Random.Range(0,basicGreetings.length)]; stringToEdit = ""; } } }

Viewing all articles
Browse latest Browse all 122

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>