|
Post by RoguesGalleryGames on Feb 16, 2018 16:23:49 GMT
Ok, I've almost completed my first level so now I'm going through adding things such as playing audio on item pickups. I looked for a vscript that would handle this, but didn't find one. I wrote my own script, and added in the parameters for OnDoAction in the investor inspector and it works...with one caveat. Sometimes, mostly if sprinting, if I hit "A" to pick the weapon or ammo up, it will play the sound as though it has been picked up, but the mesh and text are still there. They are not interactable though. As in, you can't go pick them up again. It's getting frustrating, so if I overlooked a vscript that can handle this, please point me in the right way. Lol.
Thanks!
|
|
|
Post by RoguesGalleryGames on Feb 17, 2018 15:37:16 GMT
Anybody out there?
|
|
|
Post by jrackley on Feb 17, 2018 16:24:51 GMT
In the pickup component there is an option to destroy after. You need to make sure that is checked.
|
|
|
Post by RoguesGalleryGames on Feb 17, 2018 20:56:45 GMT
In the pickup component there is an option to destroy after. You need to make sure that is checked. Yeah, I have that checked. I even have a delay of 0.2 to let the sound play all the way through. That was my own script, so I found the VPickupItem script and used it. That fixed the mesh being left behind on random occasions, but the V script will not play a pickup sound. I've looked the V script over and over, but it's just not working. Ammo is tagged as ammo, layer is trigger, destroy after is checked, on Collect Delay is Immediate, Audiosource is attached with an audioclip, and the VPickupItem script has the audiosource and the audioclip attached in the inspector in the public fields. It should work, but it isn't. I think I'm just going to have to post some screenshots of the inspector. I've fiddled with it so much, I know I'm overlooking something simple. Thanks!
|
|
|
Post by jrackley on Feb 17, 2018 22:29:58 GMT
Try increasing the destroy delay from .2 to 1 and see if that works for you. By the sounds of your description it seems you have it set up correct, however .2 may be to fast to give the audio a chance to play. This is all of course assuming you have the audioclip set in the OnDoAction part of the component.
|
|
|
Post by RoguesGalleryGames on Feb 17, 2018 22:44:48 GMT
i.imgur.com/KL5Uz6O.png i.imgur.com/lqb9fC2.pngThese are the settings I have in the inspector on my handgun ammo prefabs, but the VPickupItem script will not play a pickup sound. If i check play on awake, it will play so I know the sound is there. It should work, but it's not. Thanks!
|
|
|
Post by jrackley on Feb 17, 2018 23:56:37 GMT
RoguesGalleryGames right so you need to add the audiosource into the On Do Action, then the dropdown will appear and you need to click on audiosource and choose play. To do this click the plus sign and then drag the audiosource component that is attached into the open area on the event. That is why it is not playing you are not having it being called form anywhere. also set the destroy delay to 1. It is at 0 right now.
the time to destroy will be dependent on your audioclip, if it destroys too fast then the whole clip will not play.
|
|
|
Post by RoguesGalleryGames on Feb 18, 2018 0:31:44 GMT
jrackley, I knew it was something simple. lol. I was dragging the audioclip in where the audiosource goes in the OnDoAction. D'OH!!!
Thanks, man!!
|
|
|
Post by RoguesGalleryGames on Feb 18, 2018 1:34:12 GMT
|
|
|
Post by Invector on Feb 18, 2018 14:22:43 GMT
You set up a delay to destroy of 1 second but you also set the doActionDelay to 1 second
|
|
|
Post by RoguesGalleryGames on Feb 18, 2018 14:50:10 GMT
You set up a delay to destroy of 1 second but you also set the doActionDelay to 1 second So I need to set the delay to 1 to let the clip play, and doActionDelay to 0? Thanks
|
|
|
Post by Invector on Feb 18, 2018 15:12:09 GMT
Yes because you want to trigger the audio as soon as you give Input to do the action, otherwise the audio will play after 1 second, and by that, you also destroyed the trigger since you also set 1 second to destroy.
|
|
|
Post by RoguesGalleryGames on Feb 18, 2018 15:25:23 GMT
Yes because you want to trigger the audio as soon as you give Input to do the action, otherwise the audio will play after 1 second, and by that, you also destroyed the trigger since you also set 1 second to destroy. Great! Thanks for the help everyone!
|
|