Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Im lost

Discussion in '2D' started by WolfmanGT123, Jul 1, 2021.

  1. WolfmanGT123

    WolfmanGT123

    Joined:
    Jun 28, 2021
    Posts:
    13
    Hi everyone.
    I am new to the forum and fairly new to unity. Been playing around with it for a while and decided to make my first game, but im a little stuck.
    Now im not sure if its assets or scripts i need, but heres my situation:

    Im making a sort of quiz game, but not the normal.

    I need to get the game to ask the player a question about what item they are thinking of.
    If the game gets it right, its game over.
    If the game gets it wrong, then the player inputs the answer followed by a question for that answer.

    Once that is done, the game stores all new questions and answers ready to ask the player more questions.

    Any help would be great
     
  2. FreshYeet

    FreshYeet

    Joined:
    Oct 10, 2015
    Posts:
    12
    When I first started ever experimenting with Unity's built in UI set up I did something similar to that of which you are asking. Since you are totally new I'd suggest solely using the set up that the buttons already have for example.
    Place Text and have that text state your question. Then add 2 (Just an example) buttons Yes and No. If you click on the buttons in the editor you should see OnClick, after that point you just drag a GameObject into there and it'll let you choose built in options like Enable or Disable, (So clicking Yes would disable/hide the question and the yes and no buttons but enable the next question) Using this alone can already give you the outcome that you want however this would take a lot of time but thats just the easiest in my opinion. Of course you could easily create a script that allows you to increase an integer that could represent Numbers correct.
    So like.
    (C#)
    ExampleButtonScriptName
    {
    public float AmountCorrect;
    }

    public void Correct()
    {
    AmountCorrect = AmountCorrect + 1; (It might be += 1 I don't exactly remember)
    }

    You would put this script onto an empty game object and then drag the gameobject W/ script into the OnClick.
    Then Select Correct()

    The "Script" written above won't work like that alone but I'm assuming you have a little understanding otherwise let me know

    So if I'm correct that'll increase the float (AmountCorrect) everytime the correct button is pressed.
    Now Idk if thats going to be enough information but I never get replies on any of my stuff so I'm just genuinely trying to help you out. If you need anything further just let me know. I don't have any projects open rn but I could paste the script later if you need but that should work above of course it has no meaning really it just adds 1 everytime you click whatever button you assign it too.
     
    Last edited: Jul 1, 2021
  3. WolfmanGT123

    WolfmanGT123

    Joined:
    Jun 28, 2021
    Posts:
    13
    Thank you alot, your info has certainly opened up my eyes and given me more ideas.
    Its not actually a number game im making though.
    For example, the game asks the player is it small. The player says yes, the game then says is it a plug. Player says no.
    The player no has to enter both the answer and question for that item. For example:

    • Mobile Phone
    • Can you send a text message with it
     
  4. FreshYeet

    FreshYeet

    Joined:
    Oct 10, 2015
    Posts:
    12
    I'm not exactly sure what you mean from my understanding and correct me if I'm wrong your going for like an Akinator type thing ? Where you answer questions and then it'll guess what your thinking about or something ? Kinda irrelevant but if so you can practically make a question branch into question just based off of what you have the buttons do (enable or hide)
    My script suggestion above was more like a reference for you or whatever else to "Debug" or just have some form of information not that it was a part of the game but definitely has a role and could potentially make things easier on you because you can call it from other scripts you use. So I wouldn't totally throw out using numbers however I'm totally sure you can create the Idea you have without scripting at all If I'm correct. If you could explain a bit more, idk if I really understand what you are trying to do
     
  5. WolfmanGT123

    WolfmanGT123

    Joined:
    Jun 28, 2021
    Posts:
    13
    To put it in basic terms its like a database game.
    For example, game gets it right, then game over
    If game gets it wrong, then the play enters the right info and the game stores it for the next time
     
  6. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,343
    So TheFreshestYeeter has made a good point, and what he is suggesting is to just get the basic functionality set up and then you can build upon it. Essentially, you are looking for 2 player inputs, so you will want 2 Arrays or Lists that collect both. Like, a List called answerList and then one for questionList or something like that. When the player fills in the inputs and hits enter or submit, it will add those items to the appropriate lists/arrays.

    Get that basic functionality set up along with what Yeet is saying to create a small prototype that you can add upon.
     
  7. FreshYeet

    FreshYeet

    Joined:
    Oct 10, 2015
    Posts:
    12
    That sounds a bit more difficult, you would have to include some form of scripting and definitely well what it sounds like to me is some form of AI. I wouldn't even guess on where to begin with that but I would definitely figure out how to store Unity's Input Field UI because it sounds like your doing something more serious than just yes or no. Not too familiar with how to do that though I'm you can find it somewhere. Especially if your new to Unity I would maybe try at first making a small script that would allow you to re-use buttons instead of having hundreds and maybe even randomly stringing questions to some Text in the game. Of course even use the script I suggested before, that would be shooting yourself short but getting the hang of Unity's UI (Which isn't hard because it's pretty good imo) is probably a first thing to do.