sound-repeat

MarcoColMarcoCol Member, PRO Posts: 279
edited October 2012 in Working with GS (Mac)
Hi,
In my project, I have a sound-playing-rule, that says, that the Sound A should be played in random spaces between 3 and 10 seconds.
Mostly it works good. But sometimes when I start the project, after 3 seconds, the sound was played and then it will repeat again and again when it was finished to play - same as looped. But only sometimes !?
What is there wrong?

Comments

  • gamesfuagamesfua Member Posts: 723
    Is it perhaps because it randomly chose to play it every second or so? It appears like you said you wanted it to play randomly between 3 and 10 seconds. What if its doing just that?
  • MarcoColMarcoCol Member, PRO Posts: 279
    I chose random(3,10) and most tome it works correct. But sometimes the first play is after 3 seconds and then it will repeat each second (because the sample is about 1 second)...
  • gamesfuagamesfua Member Posts: 723
    Can you be a bit more specific on exactly what you're trying to do, and perhaps show the rules that you are using. This may better help myself and or anyone else, to help you along.
  • MarcoColMarcoCol Member, PRO Posts: 279
    Hi anatomyofdreams,

    I put a simple behavior inside my "Level-Logic" actor in the scene, which says:
    ----------
    Timer (Random)3,10 sec
    Play sound XYZ (run in completion; no loop)
    ----------
    That's it.
    with this format I also have two more "Random-Sounds" in this "Level-Logic"-Actor, and they didn't repeat all second, as the one above! But all sounds are about of 1 sec.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited October 2012

    Hi Marco

    The Timer Behaviour doesn't have "a memory"; what I mean is, whatever the first random time is, it'll continue with that same time. Then there's the problem of triggering the sound after a different random time.

    I guess there is more than one solution to these problems; this is one way to go about it (the following is off the top of my head but should work out):

    Make an integer attribute called RandT; make a boolean called Switch

    Rule: When Switch is false
    Change attribute RandT to random(3,10)
    Play Sound XYX ---- run to completion unchecked
    Timer: After RandT seconds ---- run to completion checked
    Change attribute Loop to true


    Rule: When Switch is true
    Change attribute Switch to false

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • gamesfuagamesfua Member Posts: 723
    Gyroscope has it right in my opinion. Has this helped you out?
  • MarcoColMarcoCol Member, PRO Posts: 279
    Hi.

    sorry for the late reply. It worked good.
    But one question regarding this: With one sound, everything is clear. If I use now 4 different sounds, must I then make 4 times each of the attributes and name them different or is there an easier way?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited October 2012

    Hi Marco, yes....and no... ;-) Joking apart, it depends on what you're after; you could make just one more integer attribute (let's call it SoundRand) and have 1 out of the 4 sounds randomly picked to play every random time...

    Rule: When Switch is false
    Change attribute RandT to random(3,10)
    Change attribute SoundRand to random(1,4)
    When SoundRand =1
    Play Sound 1 ---- run to completion unchecked
    When SoundRand =2
    Play Sound 2 ---- run to completion unchecked
    When SoundRand =3
    Play Sound 3 ---- run to completion unchecked
    When SoundRand =4
    Play Sound 4 ---- run to completion unchecked
    Timer: After RandT seconds ---- run to completion checked
    Change attribute Loop to true

    ----
    Rule: When Switch is true
    Change attribute Switch to false

    -----------

    Or, have the sounds play in order (but still with random amounts of time):

    Rule: When Switch is false
    Change attribute RandT to random(3,10)

    Rule: When SoundRand = 4
    Change attribute SoundRand to 0

    Change attribute SoundRand to SoundRand+1
    When SoundRand =1
    Play Sound 1 ---- run to completion unchecked
    When SoundRand =2
    Play Sound 2 ---- run to completion unchecked
    When SoundRand =3
    Play Sound 3 ---- run to completion unchecked
    When SoundRand =4
    Play Sound 4 ---- run to completion unchecked
    Timer: After RandT seconds ---- run to completion checked
    Change attribute Loop to true

    -----
    Rule: When Switch is true
    Change attribute Switch to false

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • MarcoColMarcoCol Member, PRO Posts: 279
    Hi gyroscope,

    I choose the first try and it worked perfect.
    But the last "change attribute", is it right to change attribute "Loop" to true? I think it must be "Switch", or am I wrong? Also I didn't find any attribute called Loop. And with "Switch" it worked good I think
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Whoops! Well spotted, Marco; yes, "Loop" is called "Switch" in my example... sorry 'bout the slip up but you caught it! :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • MarcoColMarcoCol Member, PRO Posts: 279
    No Problem. It shows me, that I also "understand" the solution :)
    I thank you!
Sign In or Register to comment.