Jump to content

[Solved] Teleport While Transforming


Recommended Posts

Hello,

I'm running into an issue where my character will teleport where the mouse cursor is when I perform his transform ability. Any help resolving this would be appreciated.

Spoiler

local transform = State(
        {
        name = "transforming",
        tags = { "busy", "pausepredict", "transform", "nomorph" },

        onenter = function(inst)
            inst.Physics:Stop()
        
            if inst.components.inventory:IsHeavyLifting() then
                inst.components.inventory:DropItem(
                inst.components.inventory:Unequip(EQUIPSLOTS.BODY),
                true,
                true
                )
            end
                        
            inst.AnimState:OverrideSymbol("shadow_hands", "shadow_skinchangefx", "shadow_hands")
            inst.AnimState:OverrideSymbol("shadow_ball", "shadow_skinchangefx", "shadow_ball")
            inst.AnimState:OverrideSymbol("splode", "shadow_skinchangefx", "splode")
            
            if inst.components.rider:IsRiding() then
                inst.AnimState:PlayAnimation("fall_off")
                inst.SoundEmitter:PlaySound("dontstarve/beefalo/saddle/dismount")
            else
                inst.AnimState:PlayAnimation("skin_change", false)
            end
            
            inst.components.inventory:Close()
            inst:PushEvent("ms_closepopups")

            if inst.components.playercontroller ~= nil then
                inst.components.playercontroller:RemotePausePrediction()
                inst.components.playercontroller:Enable(false)
            end
        end,

        events =
        {
            EventHandler("animover", function(inst)
                if inst.AnimState:AnimDone() then
                    if inst.sg:HasStateTag("dismounting") then
                        inst.sg:RemoveStateTag("dismounting")
                        inst.components.rider:ActualDismount()
                        inst.AnimState:PlayAnimation("skin_change", false)
                        inst.sg:GoToState("idle")
                    else
                        inst.AnimState:PlayAnimation("skin_change", false)
                        inst.sg:GoToState("idle")
                    end
                end
            end),
        },

        onexit = function(inst)
            
            if inst.sg:HasStateTag("dismounting") then
                --interrupted
                inst.components.rider:ActualDismount()
            end
            
            if inst:HasTag("DARK") then
                inst.AnimState:SetBuild("whisper_dark")
            else
                inst.AnimState:SetBuild("whisper")
            end
            
            if inst:HasTag("DARK") then
                inst.components.combat.damagemultiplier = 1.15
                inst.components.health:SetAbsorptionAmount(0.25)
                inst.components.locomotor:SetExternalSpeedMultiplier(inst, "whisper_speed_mod", 1 )
            else
                inst.components.combat.damagemultiplier = 0.75
                inst.components.health:SetAbsorptionAmount(-0.25)
                inst.components.locomotor:SetExternalSpeedMultiplier(inst, "whisper_speed_mod", 1 + .25)
             end

            inst.AnimState:OverrideSymbol("shadow_hands", "shadow_hands", "shadow_hands")
            
            if inst.components.playercontroller ~= nil then
                inst.components.playercontroller:Enable(true)
            end            
        end,
    }
)
AddStategraphState("wilson", transform)

 

Link to comment
Share on other sites

4 hours ago, RedHairedHero said:

Hello,

I'm running into an issue where my character will teleport where the mouse cursor is when I perform his transform ability. Any help resolving this would be appreciated.

  Reveal hidden contents

local transform = State(
        {
        name = "transforming",
        tags = { "busy", "pausepredict", "transform", "nomorph" },

        onenter = function(inst)
            inst.Physics:Stop()
        
            if inst.components.inventory:IsHeavyLifting() then
                inst.components.inventory:DropItem(
                inst.components.inventory:Unequip(EQUIPSLOTS.BODY),
                true,
                true
                )
            end
                        
            inst.AnimState:OverrideSymbol("shadow_hands", "shadow_skinchangefx", "shadow_hands")
            inst.AnimState:OverrideSymbol("shadow_ball", "shadow_skinchangefx", "shadow_ball")
            inst.AnimState:OverrideSymbol("splode", "shadow_skinchangefx", "splode")
            
            if inst.components.rider:IsRiding() then
                inst.AnimState:PlayAnimation("fall_off")
                inst.SoundEmitter:PlaySound("dontstarve/beefalo/saddle/dismount")
            else
                inst.AnimState:PlayAnimation("skin_change", false)
            end
            
            inst.components.inventory:Close()
            inst:PushEvent("ms_closepopups")

            if inst.components.playercontroller ~= nil then
                inst.components.playercontroller:RemotePausePrediction()
                inst.components.playercontroller:Enable(false)
            end
        end,

        events =
        {
            EventHandler("animover", function(inst)
                if inst.AnimState:AnimDone() then
                    if inst.sg:HasStateTag("dismounting") then
                        inst.sg:RemoveStateTag("dismounting")
                        inst.components.rider:ActualDismount()
                        inst.AnimState:PlayAnimation("skin_change", false)
                        inst.sg:GoToState("idle")
                    else
                        inst.AnimState:PlayAnimation("skin_change", false)
                        inst.sg:GoToState("idle")
                    end
                end
            end),
        },

        onexit = function(inst)
            
            if inst.sg:HasStateTag("dismounting") then
                --interrupted
                inst.components.rider:ActualDismount()
            end
            
            if inst:HasTag("DARK") then
                inst.AnimState:SetBuild("whisper_dark")
            else
                inst.AnimState:SetBuild("whisper")
            end
            
            if inst:HasTag("DARK") then
                inst.components.combat.damagemultiplier = 1.15
                inst.components.health:SetAbsorptionAmount(0.25)
                inst.components.locomotor:SetExternalSpeedMultiplier(inst, "whisper_speed_mod", 1 )
            else
                inst.components.combat.damagemultiplier = 0.75
                inst.components.health:SetAbsorptionAmount(-0.25)
                inst.components.locomotor:SetExternalSpeedMultiplier(inst, "whisper_speed_mod", 1 + .25)
             end

            inst.AnimState:OverrideSymbol("shadow_hands", "shadow_hands", "shadow_hands")
            
            if inst.components.playercontroller ~= nil then
                inst.components.playercontroller:Enable(true)
            end            
        end,
    }
)
AddStategraphState("wilson", transform)

 

This issue has been resolved, it's an odd issue that only seems to occur while using the Debug mode.

Link to comment
Share on other sites

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
 Share

×
  • Create New...