EmielRegis Posted February 24, 2014 Share Posted February 24, 2014 (edited) Hello. I made simple sound playing prefab. Play sound command working but when i trying to stop playing its not working and i dont know why. Help anyone?local assets={ Asset("ANIM", "anim/record.zip"), --[NEW] This is the FMOD file which contains all of the sound events. Asset("SOUNDPACKAGE", "sound/tut07.fev"), --[NEW] This is the FMOD file which contains all the actual sound data. Asset("SOUND", "sound/tut07_bank69.fsb"), Asset("ATLAS", "images/inventoryimages/record.xml"), Asset("IMAGE", "images/inventoryimages/record.tex"),}prefabs = {}local function start(inst) inst.SoundEmitter:PlaySound("tut07/musicbox/dream") end local function off(inst) inst.SoundEmitter:KillSound("dream") end local function fn() local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() local sound = inst.entity:AddSoundEmitter() MakeInventoryPhysics(inst) anim:SetBank("record") anim:SetBuild("record") anim:PlayAnimation("idle") inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "record" inst.components.inventoryitem.atlasname = "images/inventoryimages/record.xml" inst:AddTag("volume") inst.musicbox = TheSim:FindFirstEntityWithTag("musicbox") if inst.musicbox then inst.musicbox:ListenForEvent("start", function(entity) start(inst) end, inst.musicbox) end if inst.musicbox then inst.musicbox:ListenForEvent("off", function(entity) off(inst) end, inst.musicbox) end return inst endreturn Prefab("common/inventory/volume", fn, assets, prefabs) Edited February 24, 2014 by EmielRegis Link to comment https://forums.kleientertainment.com/forums/topic/31805-sound-problem/ Share on other sites More sharing options...
JackSlender Posted February 24, 2014 Share Posted February 24, 2014 (edited) The line where you choose to start the sound should look like this: inst.SoundEmitter:PlaySound("tut07/musicbox/dream", "dream") instead of this: inst.SoundEmitter:PlaySound("tut07/musicbox/dream") Tell me if that doesn't work, and I'll do my best to fix it. Edited February 24, 2014 by JackSlender Link to comment https://forums.kleientertainment.com/forums/topic/31805-sound-problem/#findComment-418814 Share on other sites More sharing options...
EmielRegis Posted February 24, 2014 Author Share Posted February 24, 2014 The line where you choose to start the sound should look like this: inst.SoundEmitter:PlaySound("tut07/musicbox/dream", "dream") instead of this: inst.SoundEmitter:PlaySound("tut07/musicbox/dream") Tell me if that doesn't work, and I'll do my best to fix it.Works perfectly, thank you very much Link to comment https://forums.kleientertainment.com/forums/topic/31805-sound-problem/#findComment-418818 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now