Please Help! Repetitive Audio Event - How do I

  • Hi Folks,

    So I`m creating a game where there will be cubes of 2 different colors and for each color there is 6 different sizes...

    They will have physics and what I`m trying to do is to play a sound for everytime any cube of any color or any size touches, without having to create an event for each possibility which would end up having too many events! I cant even calculate how many possibilities and events there would be

    How can I simplify this process?

    I thank you in advance!

  • Assuming the cubes are all separate objects here, put all of the cubes into a family then it is just one event, if Cube(family) on collision with Cube(family) > play sound.

  • Thank you !

    I will learn about families in order to accomplish this, doenst seem complicated, im just new to C2 but already very inspired.

    I will ask another question here, since I got a reply so fast, lets see if you or someone else can help me on this:

    In my game, you win when the character touches another abject, like the floor for example, and stays there for at least 2 seconds, then the system goes to the next layout. OK so far.

    But now, I want some levels to have another character (might be a copy or a different object) How can I make a condition where you only win if ALL character are touching the goal object? And considering that some levels will have a different number of these characters, so it should be a condition that doesnt state a fixed number of them to go to next layout... I hope Im making myself clear...

    I am using "if sprite is overlapping at offset" but "is touching another object" also seems to work ok.

    If someone can help me, that would be fantastic!


  • I'm using families now, very simple, very useful, thank you very much

    now everytime any block touches, a sound plays, but sometimes theres so many blocks touching and moving that there too many souds triggering! would you advise any solution to limit the number of sounds playing at once? or maybe add a milisecond break between every sound trigger?

    Hope you can reply.

  • Yep I've just worked out a nice way of doing this. Create global variable for num of players, on start of layout for each player add 1 to num players. Then second event is if player is touching goal with condition system compare if picked count = num of players > go to layout. This just checks that all players are overlapping the goal.

  • How fast are these things moving? I can try and come up with something but surely you want a sound played on every collision or it'll look a bit strange?

  • thank a lot for your time and attention

    Im learning about the global variable now.

    You are right about the boxes touching, I wish they played a sound for every touch, but sometimes it plays "too much". They are actually like cubes falling, when one fall on top of another, it trigger the sound... But sometimes a slight movement might trigger it again and again, so its a bit too much... I guess i can fix this by reducing the number of blocks in the layout too. But if you have a suggestion to have a limit of "sound per second" it should play, it would be just fantastic!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can probably toggle it off with a boolean or variable for a set amount of time. Something like if family collides w family with condition boolean =false then set boolean to true (this locks out any sounds for the time being), play sound, wait X seconds you want, set boolean to false. This should work as a toggle on/off for the sounds. Once the timer of X seconds has finished then it will play the sound on the next collision.

  • can you clarify on how can I use the "sprite.PickedCount" ? Cannot find it at all...

  • It's System > General > Compare two values. Player.pickedcount equal to numplayers

  • what if there's two kinds of sprites, and they both should be at the goal in order for the system to go to the next layout?


  • Add all of the sprites to a family and replace the sprite object in the events with the family, so for each family, family is overlapping and family.pickedcount

  • dear I also tried the first option, with only one type of sprite, but it didnt work, can you point out my mistake??? When only one sprite find the goal, its already going to next layout...

  • Use .PickedCount. .Count is the total number of instances that exist. What you are doing here is comparing how many are picked in the overlap.

  • What did I do wrong this time ?

    Now its just not going to next layout at all! <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy" /> <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy" /> <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy" />

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