Basic OR logic with 3 choices?
3absh
Member Posts: 601
I have 3 music soundtracks in my game, I want them to play randomly while playing
I'm assuming the 1st random number here is different from that of the 2nd random number
So I'm pretty sure this logic will not work,
How can I set up a logic where I make 1 random choice out of more than 2, maybe 4 or 5 choices to turn ON every time the music ends?
Comments
Have an attribute called randomNumber and then set that with Change Attribute i.e.
Change Attribute: self.randomNumber = random(1, 5)
Then have a rule like you have for each randomNumber i.e.
If self.randomNumber = 1
Play music 1
If self.randomNumber = 2
Play music 2
etc...
That logic won't work as the two rules will generate two different random numbers. Both could be 0, both could be 1, or they could be different.
You want to make a new integer attribute, and change it to random(1,3), and then have your conditions using that.
if integer = 1 play song 1
if integer = 2 play song 2
if integer = 3 play song 3
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Ok excellent guys,
but how do I make the next track play when the previous one ends?
That you need to do with a timer.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
I thought about that but problem is not all tracks are the same lenths
Something like this maybe:
If self.randomNumber = 1
Play music 1
Timer: After 60 seconds
Change Attribute: self.randomNumber = random(1, 5)
If self.randomNumber = 2
Play music 2
Timer: After 90 seconds
Change Attribute: self.randomNumber = random(1, 5)
Change each timer to match the length of the music being played in the rule.
Excellent, I'll give it a try
I built an app for a client that used tables to store the sound file lengths (I had to check each file individually to determine this) and then could use the table values to know when a sound had completed. It's tedious to set up but works great.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User