How to control 2 sounds at same time
sysads
Member Posts: 146
I have 2 actors that get spawn randomly sometimes at the same time. I have create a game integer attribute called sound.
- For actor1 - I have a change attribute to set sound to 1 when the actor spawns
- For actor2 - same attribute to set sound to 2
Then I created a controller and say when game.sound = 1, play music1
Otherwise
if game.sound = 2, play music2
This works when actors are spawn but when they spawn together, both musics play at same time/
All I want to do in this condition is, when both actors spawn together, only music 1 should play, hence music 2 should be silent. Anyone able to guide on this. Thanks
Comments
Have you tried this?
When attribute game.sound=1
Stop Music
Play Music [music1]
When attribute game.sound=2
Stop Music
Play Music [music2]
Just to clarify, when the two actors spawn together, do you want music1 to always play or only if actor1 spawned first (or only if actor2 spawned first)?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Hi, thanks for the response. I had already tried the stop attribute, it just stops the sound completely even while actors are been spawn.
Yes in event when both actors are spawn at same time, only music 1 should play. This means, there must be a way to stop music 2 from sounding while music 1 is sounding or mute music 2 when music 1 plays
Can you try this demo and let me know if this is what you're wanting?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks but whats missing is when both actors appears at same time on screen
Hi, just to make it clearer, take a look at this game for unity I came across and from 2:30, you will notice that when a new block is spawn, it plays a sound but when 2 same blocks combine together, that plays another sound but at the same time, a new block was spawn without a sound
Because actors never spawn at exactly the same instant, one actor's rules should take precedence. I changed the demo I posted so that it spawns them "at the same time" and actor 2's music plays instead of actor 1.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Is the attachment updated?
No, sorry. I just changed the spawner so that it no longer picks a random number and instead has just two behaviors (no rules):
Spawn actor [actor1]
Spawn actor [actor2]
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Sorry, I still can't get it right. Can you only give me the logic. That should allow me create the blocks. Thanks
I don't think my solution is what you really are looking for but here's the updated demo.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
The only other logic that comes to my mind is - when music 1 plays, then mute all other sounds. I only see stop music attribute but no stop sound.
Also is there plan to add feature where you can play a sound on dedicated channels meaning music 1 plays on channel 1 while music 2 plays on channel 2 and so on, so that i can then control individual channel volumes?