FleurDuSoleil3 Posted March 11, 2018 Share Posted March 11, 2018 (edited) I have created a food item that instigates a player transformation; however, the eat sound loops endlessly afterwards. I assume this is something to do with the animation not fully playing out because of how instantly the transformation takes place? I have attempted to play with the DoTaskInTime function, but can't seem to get it to work. Anybody have any suggestions? I have included the transformation script as well in case that interferes with the eating. local function becomebob(inst) inst.wererabbit = false inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild("bob") inst:SetStateGraph("SGwilson") local health_percent = inst.components.health:GetPercent() inst.components.health:SetMaxHealth(100) inst.components.health:SetPercent(health_percent, true) local sanity_percent = inst.components.sanity:GetPercent() inst.components.sanity.max = 120 inst.components.sanity:SetPercent(sanity_percent, true) local hunger_percent = inst.components.hunger:GetPercent() inst.components.hunger:SetMax(bobbi_hunger) inst.components.hunger:SetPercent(hunger_percent, true) inst.Transform:SetScale(1., 1., 1.) inst:RemoveTag("scarytoprey") STRINGS.CHARACTERS.BOB = require "speech_bob" inst.components.talker.special_speech = false end local function becomewererabbit(inst) inst.wererabbit = true inst.AnimState:SetBank("manrabbit") inst.AnimState:SetBuild("manrabbit_build") inst:SetStateGraph("SGwererabbit") local health_percent = inst.components.health:GetPercent() inst.components.health:SetMaxHealth(200) inst.components.health:SetPercent(health_percent, true) local sanity_percent = inst.components.sanity:GetPercent() inst.components.sanity.max = 100 inst.components.sanity:SetPercent(sanity_percent, true) inst.components.sanity:DoDelta(-TUNING.SANITY_HUGE) local hunger_percent = inst.components.hunger:GetPercent() inst.components.hunger:SetMax(wererabbit_hunger) inst.components.hunger:SetPercent(hunger_percent, true) inst.Transform:SetScale(1.25, 1.25, 1.25) inst.components.combat:SetDefaultDamage(TUNING.BUNNYMAN_DAMAGE) inst:AddTag("scarytoprey") STRINGS.CHARACTERS.BOB = require "speech_wob" inst.components.talker.special_speech = false end inst:ListenForEvent("oneat", function(inst, data) if data.food.prefab == "werecarrot" and not inst.wererabbit then EntityScript:DoTaskInTime(1.0) becomewererabbit(inst) elseif data.food.prefab == "werecarrot" and inst.wererabbit then EntityScript:DoTaskInTime(1.0) becomebob(inst) end end) Bobbi - Copy.zip Edited March 17, 2018 by Aquafox333 Link to comment https://forums.kleientertainment.com/forums/topic/88550-solved-looping-eat-sound/ Share on other sites More sharing options...
K1NGT1GER609 Posted March 15, 2018 Share Posted March 15, 2018 Strange I thought it had to do with the eating sound not being stopped in the wererabbit stategraph but I went with killing the sound from the werecarrot. I thought it be easier but it gets the job done: local function oneaten(inst, eater) if eater:HasTag("player") then --never know if something else eats it eater.SoundEmitter:KillSound("eating") end end local function fn(Sim)--reference on where it goes inst.components.edible:SetOnEatenFn(oneaten) so read the notes and hope this helps. Link to comment https://forums.kleientertainment.com/forums/topic/88550-solved-looping-eat-sound/#findComment-1015523 Share on other sites More sharing options...
FleurDuSoleil3 Posted March 17, 2018 Author Share Posted March 17, 2018 @K1NGT1GER609 Thanks a lot for that. It works perfectly. I think I was too obsessed with focusing on the DoTaskInTime function, despite the fact I had no clue what I was doing with it. I didn't even think about messing with the sound directly. Link to comment https://forums.kleientertainment.com/forums/topic/88550-solved-looping-eat-sound/#findComment-1016317 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