I have an array of integers representing the various collectribles in my game. When the user obtains one of the collectibles, I want to simply add 1 to the representing index’s integer. I.E., the user botains collectible 3. Index 3 changes from 0 to 1. I tried using the set array element node, but not sure I set it up right because it is outputting as zero still.
I would like to know how to do a trigger (onbeginoverlap), then once I step into the trigger get
Unreal to then show a different piece of text in the hud screen everytime I step into that trigger
area using an array to pick the text widget from out of to display.
I need to know how to set this array up.
So I can then add random greetings when I run into my NPC character in the game. It will say
random things to me from the array each time I step into the trigger area.
The array is needed for setting up all the interactive dialog A.I branching when you come
into contact with certain NPC’s in the game. They will give back a different text message
greeting when you first come into their presence and from that you can branch into more
talking with them.
That is actually a really simple thing to set up. First, create a text array. Use a differe4nt index for each random “greeting.” (i.e. index 0 says “hello.” Index 1 says “Welcome”). Then create a “Storing” integer variable (this is where you will store your random integer). Next set up your trigger and get an Event Overlap node. Drag out a “Set” of your storing integer. Off the the integer input, drag the pin out, and search for “get integer in range.” The range is the first index you want used and the last. Connect your nodes like this:
NOTE: I am using a struct in this example. For your setup, use the text array and connect the output of the “Get” node to the return node.
That should be all you need. Every time you overlap your trigger, it will generate a random integer, store it to that variable, and output the corresponding text. Hope that helps.