Jump to content

Recommended Posts

I'm attempting to introduce a pseudo-freeze effect into one of the abilities of my character, the effect is mostly the same as the normal frozen state, but needs to be silent so I can play my own sounds.

I've attempted to do this with these 2 things, but to be honest I really don't know what I'm doing. This is all I'm doing to add the states, besides changing the freezable component script to use my state instead of the normal frozen state (Just to debug for now).

AddStategraphState("wilson", 
    State{
        name = "pfrozen",
        tags = { "busy", "frozen", "nopredict", "nodangle" },
        
        onenter = function(inst)

            ForceStopHeavyLifting(inst)
            inst.components.locomotor:Stop()
            inst:ClearBufferedAction()

            inst.AnimState:OverrideSymbol("swap_frozen", "frozen", "frozen")
            inst.AnimState:PlayAnimation("frozen")

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

        onexit = function(inst)
            inst.AnimState:ClearOverrideSymbol("swap_frozen")
        end,
    }
)

AddStategraphState("wilson_client", 
    State{
        name = "pfrozen",
        tags = { "busy", "frozen", "nopredict", "nodangle" },
        
        onenter = function(inst)

            ForceStopHeavyLifting(inst)
            inst.components.locomotor:Stop()
            inst:ClearBufferedAction()

            inst.AnimState:OverrideSymbol("swap_frozen", "frozen", "frozen")
            inst.AnimState:PlayAnimation("frozen")

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

        onexit = function(inst)
            inst.AnimState:ClearOverrideSymbol("swap_frozen")
        end,
    }
)

If there is a proper tutorial on adding states I would love a link!

Link to comment
https://forums.kleientertainment.com/forums/topic/126631-creating-new-states/
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
×
  • Create New...