News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

problem with playsnd

Started by demongorne, March 12, 2015, 06:14:42 PM

Previous topic - Next topic

demongorne

I would like have two sound effect for the same animation in such a way that the sounds effects are played randomly

I put this in statedef 3700  -   
[State 5300,PlaySnd]
type = PlaySnd
trigger1 = time= 0
value = 5300,1

ESFAndy011

#1
Use +random%x, where x is the amount of sounds you would like to be played randomly.

value = 5300,1+random%2

In this case it will either play 5300,1 or 5300,2.
Quote from: Millie, "Ozy and Millie""I think there are really three types of people: "Glass is half-full" sorts of people, "Glass is half-empty" sorts of people,
and people who will spit into the glass until that's fixed."

ZzEzZ

or you could have it as


value = 5300,(random<500)

Then first sound is 5300,0 and second sound is 5300,1

Алексей

It's better to use modulo (the "%" sign) as it's cleaner and easy to make changes to in the future. If he adds a sound, all he needs to do is change %2 to %3 and he's good to go, but with (random<500), you'll always get either 0 or 1 as the answer.

-[Все слова это только слова.]-