Announcement

Collapse
No announcement yet.

' Play a sound file - show widget - click answer - play a sound file...'- type game with Blueprints?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ' Play a sound file - show widget - click answer - play a sound file...'- type game with Blueprints?

    Hi all!

    I'd like to do a simple 'answer the question' game. The engine should play the audio (question)-> then shows a widget-> player clicks the answer (yes or no..I already have this widget clickable)-> then it plays another sound file (question 2) according to the answer -> widget-> click...and so on.
    How can I do it with blueprints?

    Thanks!

    #2
    I have a widget in the scene.
    I'd like to check in the Level Blueprint if the Yes or the No button was pressed on the widget. If the widget's 'yes' button, then sound file nr.1 should be played, if the 'no' button, then sound nr. 2.
    Can anyone point me in the right direction?

    Thanks!

    Comment


      #3
      As far as I know, this would be the handiest way:

      1. You add a Structure Blueprint to your context browser.
      Click image for larger version

Name:	addstructure.jpg
Views:	1
Size:	76.7 KB
ID:	1126204

      2. You open your Structure Blueprint and set the following variables:
      Click image for larger version

Name:	Stract.jpg
Views:	1
Size:	66.9 KB
ID:	1126205

      3. Next you add a DataTable to your context browser.
      Click image for larger version

Name:	AddDataTable.jpg
Views:	1
Size:	72.4 KB
ID:	1126206

      4. When you add the DataTable there will pop up a little window. You just select the Structure Blueprint which you created before.
      Click image for larger version

Name:	ConfigDataTable.jpg
Views:	1
Size:	12.7 KB
ID:	1126207

      5. Open the DataTable and you can easily add as many questions (with the correct answer) as you want.
      Click image for larger version

Name:	DataTable.jpg
Views:	1
Size:	73.0 KB
ID:	1126209

      5. Then you create a "MainWidget" with a "Start Game" - Button. This Button will open another widget which I call "AnswerWidget" with the Yes/No-buttons (which you have already created).

      6. The EventGraph of "AnswerWidget" could look like this:
      Click image for larger version

Name:	Widget.jpg
Views:	1
Size:	441.3 KB
ID:	1126208
      Basically you just take the information out of the DataTable and choose one question through a randomly generated variable "RandomID".
      When you now press the Yes/No button, it will check if that answer is the same as in the DataTable.

      I didn't test it, so... hope it works and helps.
      Of course you should add other stuff. For example to avoid getting the same question two times.

      Cheers
      Attached Files
      Last edited by Herbie53; 04-09-2017, 04:06 PM.

      Comment


        #4
        Hi!

        Thanks for the detailed explanation, I'll go through it!

        However, there will be no right or wrong answers. I just need the engine to play the next question audio file according to what was pressed before.
        For example: 1st question: 'Are you tall?' ---> Answered by pressing YES button -> Next question audio to be played: 'Are you above 180cm?'
        But if the player pushed the NO button then the next question audio will be the 'Are you shorter than her?'
        See branch image:
        Click image for larger version

Name:	widget_answering.jpg
Views:	1
Size:	126.8 KB
ID:	1126225

        Comment


          #5
          Just a few changes - you can still use the DataTable
          DataStract and DataTable:
          Click image for larger version

Name:	DataTable.jpg
Views:	1
Size:	133.3 KB
ID:	1126227

          Now you can just replace the random Generator with a next QuestionID from the DataTable.
          In my case, I made it randomly generate the first question and then choose the next question after what is given in the DataTable:
          Click image for larger version

Name:	Widget.jpg
Views:	1
Size:	434.3 KB
ID:	1126228

          Comment


            #6
            Looks intimidating.
            Will go through and test it, thank you!

            Comment


              #7
              It's overcomplicated I think. Ok, here is a more precise example what I would like to play through. The questions should be text written on the 'HUD' (no matter where the camera looks, should be always facing the screen) and audio played as well.
              (Keys pressed would be y for Yes, n for No)
              Click image for larger version

Name:	Graph.jpg
Views:	1
Size:	114.1 KB
ID:	1126248

              Comment


                #8
                There are three separate parts to your solution:

                1) How to display text (or play sounds) on the screen

                2) How to let the player make choices

                3) How to react to the player choices to display new text


                To solve this, you could have a Blueprint class with text fields for "text to display" and an array of "choice text, target blueprint instance" for the chocies.
                You then create a UMG User Widget that knows how to take an instance of this Blueprint, and fill out its "text displayed" and "possible choices" sub-widgets.
                You then make the "possible choices" sub-widgets have an action that, when clicked, follow the "target blueprint instance" part of the choice, and tells the UMG User Widget that there's a new Blueprint instance that's now active. The UMG widget will then update its display.

                You need to bootstrap this somehow by creating the widget, and configuring it with the "root" (first) question. You can do this in your level blueprint.
                To configure the flow of questions/answers, create new instances of the Question Blueprint for each question, and configure the "blueprint after answer" field of each answer to some other Blueprint instance you've created.
                It may be best to first create all questions/answers, and then go back and "link" each of them to the proper next question.

                Comment


                  #9
                  I'm trying to tell the Level Blueprint (after played the intro sounds ) to activate QuestBlueprint nr1 (which has Widget nr1 as component - it draws text) and wait for input and when Y pressed play a sound and activate QuestBlueprint nr2 (draws text ) or if N was pressed play a different sond and activate QuestBlueprint nr3 ? And so on...?

                  Comment

                  Working...
                  X