sounds and variables

0 favourites
  • 11 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello friends, I was wondering how I'd go about making an object change its sound every time you touch it (cycling through 5 different sounds over and over.) I know I should probably use a variable to change the sound, just not sure how to implement it properly. Any help would be great, thanks!

  • Random sounds or in the same order?

    OnTouch > Add 1 to variable

    If variable = 1 > Play Sound 1

    if variable = 2 > Play Sound 2

    etc.

  • Thanks Plinkie. Actually Im looking to do random sounds on one object and another object with sounds cycling in order. My problem really is finding the action under my object that plays the sound controlled by the variable. Im sure its something easy, maybe Im just being lazy haha..I'll keep plugging away at it.

  • Just link a sound up to a number. If variable is 1 then play sound 1 etc. easy! If you want to do a random sound it'll be something like OnTouch > variable = rand(min,max). This will set the variable to a random number and play the sound linked to it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Okay Plinkie I get the logic but cant find the command to check the variable, the "if variable =", how do i do that check then play a sound. Thanks a million

  • I cant seem to compare the variable inside the object as an action

  • Add Event > "Object" > Compare Instance Variable

  • To play random sounds you can use the choose command. In these examples I'll asume you have 3 sounds.

    On object touched - play sound: choose("sound1","sound2","sound3")

    For the sounds in order give the object an instance variable sound

    on object touched - object add 1 to variable sound.

    (subevents)

    -object compare instance variable = 4 - object set variable soundd to 1

    (subevents)

    -object compare instance variable = 1 - play sound: "sound1"

    -object compare instance variable = 2 - play sound: "sound2"

    -object compare instance variable = 3 - play sound: "sound3"

  • Amazing help and super quick responses, mucho love to you! Thanks

  • how about when you go to other layout sound well change how to do that..?

  • OnStartOfLayout event > Play Sound action

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)