EmielRegis Posted February 24, 2014 Share Posted February 24, 2014 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) Link to comment Share on other sites More sharing options...
JackSlender Posted February 24, 2014 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. Link to comment 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 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.