Jump to content

Recommended Posts

Hi all,

 

I'm relatively new to the modding scene, been piecing everything together myself but I've run into a bit of a snag. I've made custom sounds for a handslot-equippable item but there's a particular sound I want to run indefinitely while the item is equipped and stop when unequipped.

 

I used the code from the torch.lua as a basis - "inst.SoundEmitter:KillSound("torch")" seems rather straightforward but imitating it in my own code nets no results. The sound plays just fine, but won't stop after I've unequipped the item. (Side note: the sound being killed in torch.lua doesn't include the filepath when being played or killed - seems odd, is this something to do with the issue I'm having?)

 

Has anyone else attempted something similar and has any tips they'd like to share? I've probably just overlooked something simple, but any help would be much appreciated.

 

Thanks in advance!

@patriciancat,

in "inst.SoundEmitter:KillSound("torch")" the word torch referes to the soundname not the prefabname(not sure if that was clear to u).

so if u start your sound with your own soundpath(which is btw not the folders in the filesystem, but the soundpath from your custom soundfile, see soundtutorial) lets say inst.SoundEmitter:PlaySound("character/character/fart") then u also have to kill it like this: inst.SoundEmitter:KillSound("character/character/fart")

and ofc inst still has to refer to the same entity.

Edited by Seiai

@Seiai,

Thanks for replying. Yes I do know "torch" refers to the soundname here - The sound is playing correctly, so I don't think the issue is with the filepath. For a clearer example of my code, I have in the OnEquip function:

 

inst.SoundEmitter:PlaySound("xxxx/xxxx/xxxx")

 

which works correctly - the sound plays when the item is equipped. It's meant to be a sort of humming noise, so it plays for a while, but I'm trying to stop the sound from playing too long. So in the OnUnequip function, I have:

 

inst.SoundEmitter:KillSound("xxxx/xxxx/xxxx")

 

which does not stop the sound, hence the issue I'm having. The filepath is identical in both instances, so I can only assume I'm using KillSound incorrectly.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...