Play sound for multiple answers in quest data table

Hi so , I have a quest system with some data tables from structs. Basically the NPC talks and player has answer fields . there is field called "Answer Sound " to play sounds during answers. With one answer in , this all works fine , but if I have more than one answer , then the sound always plays the last answer sound , even if I click the first answer. The answer I click will advance the quest correctly , but its just the sound that always plays the last answer (or it may actually be playing both answers in order , but I only hear the last answer). Like the sound cannot distinguish between which answer I clicked. One pic is the Answer struct for the data table . Basically if I add a second answer in the data table, that set of fields doubles and the first answer becomes answer 0 and second answer becomes answer 1 ,. and so on. The other pic is the code how the answer sound is played. Any ideas on how to get the correct sound to play for which answer is clicked?

This is how the answer section in the data table looks , I tried adding the “answer index” integer variable to see if I could use that to differentiate , but no luck.

Why are you doing a For Each Loop ? It seems you are going through all the array of answers struct and play the sound of all of them, and since you are setting them all in the same audio component, then only the last one we will be played (since you override the assignment of the previous sound by using the same sound component in the For Loop ).

You should be retrieving from the array only the answer that the player selected, and play only that sound in your sound component.

I also noticed that you pass an Element variable in your event call, if that is the index of your answer, then you should use that one to retrieve the correct sound from the array of answers.

thanks for reply , well the “answer index” variable is on the answer struct now. It don’t show in the pick above , must not have been on yet. I only used the for each loop so I can break each struct open and access the answer struct. Is there a better way? I can pull off the " answer index" variable on the answer struct but I wasn’t sure what nodes to put in there to retrieve the correct sounds from the answers. this is how answer struct is now.

The blue line on the upper left by the yellow arrow is coming in from here.

So it is breaking the segment , then going down to the " for each loop" , which from there it is breaking the answer struct.

So i’m coming off the for each loop array element pin the break the answer struct and access it.

What nodes would I use to retrieve the correct answer sounds?

What I mean is that in your example, you have two possible answers “Nah” and “I will go”, and if I understood correctly, you need to play only one of these two.

You have an array of answers which is contained in a struct called STR_DS_Segment (which I assume it represents a single quest or a fragment of a quest which has different possible answers).

If you need to play only one answer, how do you know which one you need to play? You will need an index (and it is not on the answer struct). This index will indicate to you which answer you will need to play. In this case, instead of a For Loop, you will need to use a Get from the array by using this index.

On the other hand, if you want to play all the answers in order, then you should use a timer to play each of the sounds and start the next one once the first one finished. If this is your case, I can show you how.

yes it is part of a quest dialogue that has multiple answers. The answers when added in the data table become 0 and 1. I added a 2nd sound wave for the second answer , tried the " get " node to break the answer struct. But even with the " get" node it always plays the first answer sound , then if I connect the “element” variable to the " get " node it always plays only the last answer sound. I mean when I click the first answer text it advances the quest properly , or if I click the second answer text , it also advances the quest properly according to that answer , it’s just the sound that’s a problem.
So are you saying the index would not be put on the answer struct , but somewhere else? If so , where? Any chance you could throw a couple nodes together in a pic to give me an idea of what need to be done? This been driving me nuts , because I tried so many different things. thanks

Yea it wouldn’t be an “in order” thing , it would be picking one answer or the other.

Help! Help!