Forum Discussion
Random value - link button to content slide
I use a random generator variable to randomly select which state of a button would appear when clicked. Then, I wanted to use that state/button to be used to go to that specific activity. For example State 1 would turn into a button that went to Slide 1 Activity.
The random generator worked. But the button to go to the corresponding activity did not. I'm wondering if I should have used layers, with a different button on each. Can you randomize which layer shows up?
Or is there an easier way to do this?? I want a button to randomly pick an activity for the student to do. And I need the corresponding slides to be accessed based on that activity. Thanks!!
- RonPricePartner
Are you able to share your Story? That would help great deal in determining why your build does not work.
- Nathan_HilliardCommunity Member
Can you provide an example project file of what your current setup is?
Yes, you should be able to set states that dispaly alternate buttons set to go different places. They could also trigger different layers to show or hide.
It might be easier to just create a random number variable, say ranging from 1 to 10, and set it with the random value. Then, depending upon how your button is designed, you could set a text variable to a specific value based on the random number selected. The text variable would be used as the label for the button. Upon clicking the button, you could just use triggers that check the value of the random variable and either jump to a specific slide or show a specific layer accordingly. This way, you would only need one button and wouldn't have to create a bunch of complicated states with different trigger targets.
- JanetNesseth-2aCommunity Member
I have 2 scenes in this example. I tried different methods in each scene. The second scene seems to be easier, but every time I go back to the first slide, it should reset to initial state, but when you click the button to get a random number, it goes to the same number every time. In fact - I could only get 1 and 4 to show up, even if I closed it. ?
- Nathan_HilliardCommunity Member
Your Scene 2 does not seem to be setting any random numbers. You're only doing that in Scene 1.
- Nathan_HilliardCommunity Member
I had a chance to look at it and yes, your Scene 2 solution seems to be the most straightforward. Just add a trigger to set the random value on Blue Button click, and move it to the top of the stack.
I cycled through several clicks and visits to all 4 layers were generated.
- NedimCommunity Member
I would never go with Scene 1 option. In Scene 2, as Nathanial pointed out, you should add a trigger that generates a random number when the randomizer button is clicked. Attached is my solution with one button.