Ziro2k Posted September 23, 2017 Share Posted September 23, 2017 Greetings. Usually I can find the solutions to any problems I come across by searching around on this forum, but I'm stumped and I can't seem to find any similar experiences. In my mod I'm creating a custom ability for WX-78, where the player can hold Rshift in order to charge another player in range with a buff, until they let go. The ability itself is functionally fine, it just looks atrocious. I'm using the in game "channeling" animation for the ability and while it does execute, the problem is that it doesn't prevent other animations, namely the idle animation, from interrupting it. The result is WX-78 flickering every few seconds between the channeling and idle animations, before returning to channeling. The code for the ability is: function shock_charge(player)-- Rshift ability for WX-78. Hold to temporary charge a nearby ally. if not GLOBAL.TheWorld.ismastersim then return end local current_target local ps local old_target = nil let_player_move(player, false)--disable player movement player.components.locomotor:Stop() -- stop movement player.components.locomotor:Clear() player:ClearBufferedAction() -- and any actions you were going to do player.AnimState:PlayAnimation("channel_pre") player.SoundEmitter:KillSound("charge_sound") player.SoundEmitter:PlaySound("dontstarve/characters/wx78/charged", "charge_sound") shock_charge_task = player:DoPeriodicTask(TUNING.WX78ShockChargeSpeed, function(player) if not player.AnimState:IsCurrentAnimation("channel_loop") then --refresh channel animation incase somehow knocked out of it player.AnimState:PlayAnimation("channel_loop", true) end current_target = nil-- get new current target every cycle if player:HasTag("charging") and not player:HasTag("groggy") and not player:HasTag("playerghost") then current_target = FindClosestPlayerToPlayerInRange(player, TUNING.WX78ShockRange, true) if current_target == nil and old_target == nil then --no players in range, and no previous target, do nothing player.components.talker:Say("SEARCHING FOR TARGET...",2.5,true) elseif current_target ~= nil and old_target == nil then --player in range, no previous target, initialize buff ps = current_target:GetPosition() player.components.talker:Say("TARGET ACQUIRED",2.5, true) SpawnPrefab("shock_fx").Transform:SetPosition(ps:Get()) charge_ally(current_target) old_target = current_target elseif current_target == nil and old_target ~= nil then discharge_ally(old_target) old_target = nil elseif (current_target ~= nil and old_target ~= nil) and current_target ~= old_target then discharge_ally(old_target) charge_ally(current_target) old_target = current_target elseif (current_target ~= nil and old_target ~= nil) and current_target == old_target then end else if old_target ~= nil then discharge_ally(old_target) old_target = nil end let_player_move(player, true)--enable movement player.AnimState:PlayAnimation("channel_pst") player.SoundEmitter:KillSound("charge_sound") shock_charge_task:Cancel() end end) return end The key relevant parts are: player.AnimState:PlayAnimation("channel_pre") ---when the function is first called ... if not player.AnimState:IsCurrentAnimation("channel_loop") then ----(when it repeats) player.AnimState:PlayAnimation("channel_loop", true) end ... player.AnimState:PlayAnimation("channel_pst")--- when it ends I know I can't be utilizing this correctly. So, is there a way to prevent other animations from interrupting ones that I manually call? Or better yet, is there a way to make my character do the channeling animation other than by manually calling each animation state? Any help is appreciated, thank you. Link to comment Share on other sites More sharing options...
ZupaleX Posted September 25, 2017 Share Posted September 25, 2017 You should create a proper state for the stategraph and put relevant StateTags like "busy" to that new state so the idle anim cannot interrupt it. Link to comment 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