Randomized character speech

Hello,

I am wanting to have my player approach a character that “talks” when my player gets close, but also says different things each time. I have attached my attempt, but it isn’t working the way I want it to.

I would recommend using a Text List for this.
What a text list does is store a List of values in it.

So what you showed would be
[Label1, Label2, Label3, Label4]
You would use the Random behavior into the “One” input on the Text List, and the output would go to the “Value” input on the Label

If you want I can send over a screenshot of what this would look like.

3 Likes

the “alpha” input in a label object is how transparent it is, on a value from 0 to 100. your random is outputting a random number 1-4, which will set the alpha of all text from 1/100 transparency to 4/100 transparency

To fix this, you should first attach “equal to 1” “equal to 2” etc etc filters before each label, which will send a signal to the alpha of only one text block.

Then, the output for the filter should be attached to a “100” number, which is then attached to the alpha.

you’ll also need a timer after activating the random for when the text goes away. If you want, I can put together a quick example :slight_smile:

5 Likes

A screenshot would be awesome! (I am a beginner, this is my first game)

4 Likes

If this is your first game, I would suggest using Sup3r’s method as it is a little easier for a new user to understand, but both methods will work well. Alpaca’s is more sophisticated, it just depends on how you want your code

3 Likes

Could I get an example please?


Lists are a little complicated at first, but learning how to do some basic things with them early on can really help in development later on and make things much easier.

What’s happening here is the “One” input will look for what’s in the spot of the number that was used as an input.
So if 2 was given as the input, the Output of “One” would be “Label 2” Because it is in the 2nd spot within the list.

2 Likes

Thank you, this is a great solution!

4 Likes