Please Help! Repetitive Audio Event - How do I

Get help using Construct 2

Post » Thu Oct 27, 2016 1:26 am

:?:

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!
B
16
S
7
Posts: 56
Reputation: 1,402

Post » Thu Oct 27, 2016 1:56 am

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.
B
46
S
16
G
73
Posts: 2,080
Reputation: 43,669

Post » Thu Oct 27, 2016 2:15 am

Thank you @plinkie !

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!

Thanks!
B
16
S
7
Posts: 56
Reputation: 1,402

Post » Thu Oct 27, 2016 2:24 am

@plinkie 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.
B
16
S
7
Posts: 56
Reputation: 1,402

Post » Thu Oct 27, 2016 2:43 am

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.

Image
B
46
S
16
G
73
Posts: 2,080
Reputation: 43,669

Post » Thu Oct 27, 2016 2:45 am

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?
B
46
S
16
G
73
Posts: 2,080
Reputation: 43,669

Post » Thu Oct 27, 2016 2:49 am

@Plinkie 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!
B
16
S
7
Posts: 56
Reputation: 1,402

Post » Thu Oct 27, 2016 2:58 am

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.
B
46
S
16
G
73
Posts: 2,080
Reputation: 43,669

Post » Thu Oct 27, 2016 3:14 am

@plinkie can you clarify on how can I use the "sprite.PickedCount" ? Cannot find it at all...
B
16
S
7
Posts: 56
Reputation: 1,402

Post » Thu Oct 27, 2016 3:23 am

It's System > General > Compare two values. Player.pickedcount equal to numplayers
B
46
S
16
G
73
Posts: 2,080
Reputation: 43,669

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests