Request - Random method inside a button

Waslikethem

Active member
Messages
109
Reactions
30
Points
28
Inside a simple UIButton you can add an actions, why no one thought about adding a RANDOM action to be accourd once you are pressing the button, it's very easy thing to do in coding, didn't saw any plugin that do that so far...

Can someone make that happened?
 
What you want is RandomChoice LogicBrick, it does exactly what you want, and check out other Logic Bricks, its awesome too!

 
Well, i added 'MacGruber.RandomChoice' into my Scene but i don't know how to procced from here... how i connect that into a UIbutton that will trigger randomly?
 
Last edited:
Well, i added 'MacGruber.RandomChoice' into my Scene but i don't know how to procced from here... how i connect that into a UIbutton that will trigger randomly?
LogicBricks has a couple of example scenes that come in a separate package. Have a look at example 12:
1677738679074.png

Button triggers the RandomChoice brick which can be anywhere in your scene:
1677739000528.png

In the plugin you setup a number of "Choices" and what trigger action to do for each of them:
1677738920392.png



As a more complete intro into LogicBricks I recommend my video tutorial series about LogicBricks:
 
In order to make that work i must have 1 Coliision Trigger with 3-5 spheres below him? i didn't get it, the collision trigger, trigger the spheres randomly?
 
In order to make that work i must have 1 Coliision Trigger with 3-5 spheres below him? i didn't get it, the collision trigger, trigger the spheres randomly?
Uh, there seems to be some missunderstanding. There are no CollisionTriggers involved in that example. Also the spheres are just there to visuallize that something is triggered (they all have a "Blend" brick each that handles fading in/out the red color). All you need is a RandomChoice brick. Trigger that, then the brick will trigger stuff randomly for you. Just look at the example scene. It's not that complicated?
 
Seems like yeah, for me at least, i'm new for Virt a Mate.
I will tell you what i'm trying to achive:
I've already created a button that trigger femqle voice output, each time i'm pressing on the button she's saying 1 sentence.
I want to add more voice sentences for that button and each time the button will be pressed she will randomly say something else.
In theory it sould be very easy thing to do specialy when it comes to coding, just trigger 1 random voice line and return the method.
Can you help me with that, or give me a little bit more deep explnation how i can make that happened with your plugin
 
Seems like yeah, for me at least, i'm new for Virt a Mate.
I will tell you what i'm trying to achive:
I've already created a button that trigger femqle voice output, each time i'm pressing on the button she's saying 1 sentence.
I want to add more voice sentences for that button and each time the button will be pressed she will randomly say something else.
In theory it sould be very easy thing to do specialy when it comes to coding, just trigger 1 random voice line and return the method.
Can you help me with that, or give me a little bit more deep explnation how i can make that happened with your plugin
As noted, MacGruber's Logicbricks allow you to do that, in several ways actually. See the video. I would use the logicbrick RandomSound instead of RandomChoice, as it's simpler to grasp and expand for your usecase.
Other options are AudioMate, JayJayWon's ActRandomizer, and I'm sure others if you search the hub.
 
more deep explnation how i can make that happened with your plugin
That's what the tutorial videos I mentioned are for. There is like an hour worth of video just about LogicBricks. You may also want to watch the one about Triggers, although you seem to have them mostly figured out yourself already. Anyway, the first LogicBricks tutorial has actually an example using RandomChoice starting around time index 6:20
 
Note: There are also RandomSound and RandomSoundFromAB plugins included in LogicBricks that are specifically made to play sounds at random. However, I recommend to try to understand the RandomChoice plugin first. Once you get the hang of it, it should be straight forward as those bricks are all pretty similar.
 
Thanks, after watching the tutorial i've understand how the RandomChoice exatcly work. When you pointed me to the first video i got a little bit confused with all the spheres.
 
Back
Top Bottom