Download

' 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!

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? :slight_smile:

Thanks!

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

  1. You add a Structure Blueprint to your context browser.
    addstructure.jpg

  2. You open your Structure Blueprint and set the following variables:
    Stract.jpg

  3. Next you add a DataTable to your context browser.
    AddDataTable.jpg

  4. When you add the DataTable there will pop up a little window. You just select the Structure Blueprint which you created before.
    f8463bc80e46c2324c21f60ab7524a2f621ffdec.jpeg

  5. Open the DataTable and you can easily add as many questions (with the correct answer) as you want.
    d10ba396fc22f29d168924c85c31bb7cd2eb7270.jpeg

  6. 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).

  7. The EventGraph of “AnswerWidget” could look like this:
    Widget.jpg
    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

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:
6ae82ede56edb711a7f313afd7479859bbe9ac5e.jpeg

Just a few changes - you can still use the DataTable
DataStract and DataTable:
DataTable.jpg

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:
Widget.jpg

Looks intimidating. :smiley:
Will go through and test it, thank you!

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)
Graph.jpg

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.

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…?