playMaker

Author Topic: Looping a Oneshot sound  (Read 3280 times)

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
    • View Profile
Looping a Oneshot sound
« on: November 09, 2013, 05:54:22 PM »
Probably the wrong way to do this.

I use this exact FSM to do a splash sound when the player jumps in the lake. different audio file of course)
But when I want to trigger the sound of being underwater, it needs to loop until the player comes out.
But as Play Sound just spawns a OneShot Audio thingy, the file cannot be set to loop, so I just hear a half second of the file, and then nothing...
How should I do this?

Mark

uberwolfe

  • Junior Playmaker
  • **
  • Posts: 59
    • View Profile
Re: Looping a Oneshot sound
« Reply #1 on: November 09, 2013, 06:20:39 PM »
Try to use Audio Play instead of Play Sound.

You can then set the loop very easily and also have better control for stopping the sound when your player resurfaces.

Something like this I guess:


You then send Audio Stop when the player resurfaces.

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
    • View Profile
Re: Looping a Oneshot sound
« Reply #2 on: November 10, 2013, 07:01:02 AM »
Thanks for that. Im trying it but not working yet.
Im using the system event On trigger enter for the splash, with the one shot sounds. With no idle state, See prev image... should this work, I dont really know how to hook up an exit event though.

Bjakuja

  • Junior Playmaker
  • **
  • Posts: 75
    • View Profile
Re: Looping a Oneshot sound
« Reply #3 on: November 10, 2013, 11:57:36 AM »
Hi!
Easies way to do what you want I believe would be to add component audio source some empty game object that is parented to your character and in the inspector set it to loop. Then you can deactivate that object while off water. When you are in water you can activate that game object with audio source and loop will continue until you exit from water and deactivate that game object again.

Helped?

Cheers!

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
    • View Profile
Re: Looping a Oneshot sound
« Reply #4 on: November 10, 2013, 12:42:45 PM »
Maybe...
Just a quick question to everyone really.
Is it normal that your player ends up with SHIT loads of things to carry around? Mine has already got about 10 FSMs that do various things at various times. I was hoping to add the component to the Thing that needs it in this case... the water.
BUT.. of course an audio source has to be located around the Player.

Mark

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14342
  • Official Playmaker Support
    • View Profile
Re: Looping a Oneshot sound
« Reply #5 on: November 10, 2013, 10:49:30 PM »
Hi,

 Yes, it's very common to get a lot of fsm to provide all your functionalities.

 Organize all the fsm that doesn't need to be on the gameobject itself as childs of it to make the unity inspector less crowded. Only keepo the one like using triggers on the proper gamobject, the rest can referenbce it and work on its own inside a hierarchy.

bye,

 Jean