Hello fellow Unity enthusiasts.
I am trying to create a sort of “Decision Maker” in Unity.
The basic requirements are that it can import a list of words/ phrases (array of strings) via a spreadsheet or something similar and “randomly” pick one of the words/ phrases (after the user pushes a button) and then highlight it.
Visually this could be portrayed in several ways. The “magic 8 ball” method would be more random whereas the “Wheel of fortune” method would be based on inertia. (not necessary for user input… could just be a button press that spins the wheel).
I’ve done alot of searching but haven’t found anything for helping me get started.
Any suggestions?
magic 8 ball:
I would just create an array of words
then at random choose one.
As for the Wheel of fortune, do you mean to spell board or spin wheel?
If is is the spell board the same method applies as above. Not that hard I would think.
What do you need help getting started on?
Create a text file, with your words and phrases, and give each phrase an id in the file… i.e
1,The cat sat on the mat
2,The mat sat on the cat
3,blah blah blah
Do a random.range call, to randomly select a phrase to display.
Use physics for a simple wheel spin.
Ok, I guess my question wasn’t detailed enough…
@renman3000 - for the Wheel of Fortune I mean to spin the wheel and display each input phrase on each slice of the wheel and then highlight the winning phrase
@Meltdown - I want the user to be able to upload the txt file and my app will do some sort of jumble animation to then show the randomly chosen phrase. Im thinking that would be better than the wheel route but it would be nice to know both. So how need to know how to:
- Have user upload file .txt
- read that file and show all the phrases on screen
- user pushes a button to randomly move /jumble all the words on screen and after a few seconds form/ show the randomly chosen phrase.
thanks.
Ok. I have collected my thoughts a bit better and started the script and posted to pastebin. Please help with the bits that are commented out.
http://pastebin.com/8uP11bUP
//Decision Maker
//Notes: Bonus: options for not repeating chosen phrases
function Update ()
{
}
function OnGUI ()
{
if(GUI.Button (Rect(10,30,80,30), "Upload list file (.txt)"))
{
// 1. show OS file browser with "import" button.
// 2. if (import button is pressed after user chooses file with appropriate extension)- upload file and display list of phrases clearly seperated
// 3. after successful import, show "Choose for me" button
// 4. if ("Choose for me" button is pressed )- animate / jumble all of the phrases
// 5. wait a few seconds for animation to complete and then highlight/ show the randomly chosen phrase and play sound.
}
}
And have various randoms strings per level?
Sure, just create something like this… keep in mind I have not tested, nor used random, so I am not sure if this is functional but it is the idea.
var randomString : String[];
var panel : GameObject[];
function Start()
{
for(var i : int = 0; randomString.length; i++)
{
var randomStringInt = int;
randomStringQuote = Random.Range(minString, maxString);
panel[i].Text = randomString[randomStringQuote];
}
}