Jump to content

Animations not working right while moving


Recommended Posts

I am attempting to have my character go into a pseodo-frozen state when an ability is triggered, essentially just frozen visually, the problem I'm facing is whenever my character is moving while this frozen state is triggered, she doesn't properly freeze, instead just changing the color of her tint. Here is a visual example.

Still:

.still.thumb.gif.ae02959f6a58089cd5840c0d83ff26b4.gif

Moving: .moving.thumb.gif.15dc8d284ed5a8436bf0e7c761b24404.gif

As you can see, the moving one is a bit wrong. I have no idea where this problem is rooted, as the ability automatically stops my character from moving right before putting them into the frozen state.

This is the code I'm using for the weird half-frozen state I made

local function FakeFreeze(inst)
  
 --This is essentially just modified freezable:freeze code, along with modified frozen stategraph code
  
	local owner = inst.components.inventoryitem.owner
	
	if owner.components.pinnable ~= nil and owner.components.pinnable:IsStuck() then
		owner.components.pinnable:Unstick()
	end

    if owner.components.inventory:IsHeavyLifting() then
        owner.components.inventory:DropItem(
        owner.components.inventory:Unequip(EQUIPSLOTS.BODY), true, true)
    end
	
	owner.components.locomotor:Stop()
	owner:ClearBufferedAction()


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

	owner.components.inventory:Hide()
	owner:PushEvent("ms_closepopups")
	if owner.components.playercontroller ~= nil then
		owner.components.playercontroller:EnableMapControls(false)
		owner.components.playercontroller:Enable(false)
	end
	UpdateTint(inst)
end

How can I fix this, if it's even possible?

Edited by TheSkylarr
Link to comment
Share on other sites

I think it is because you're still pressing 's' button, so game recognizes input is there so anim doesn't appear.

I've searched through SGwilson, I guess this is sort of 'ignore inputs for some time' command:

inst.sg:SetTimeout(FRAMES)

So I think this should work:

make ignore your input for 2 frames so anim will 'blink' while no inputs are active.

local function FakeFreeze(inst)
  
 --This is essentially just modified freezable:freeze code, along with modified frozen stategraph code
  
	local owner = inst.components.inventoryitem.owner
	
	if owner.components.pinnable ~= nil and owner.components.pinnable:IsStuck() then
		owner.components.pinnable:Unstick()
	end

    if owner.components.inventory:IsHeavyLifting() then
        owner.components.inventory:DropItem(
        owner.components.inventory:Unequip(EQUIPSLOTS.BODY), true, true)
    end
	
	owner.components.locomotor:Stop()
	owner:ClearBufferedAction()
  
	owner.sg:SetTimeout(2 * FRAMES)

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

	owner.components.inventory:Hide()
	owner:PushEvent("ms_closepopups")
	if owner.components.playercontroller ~= nil then
		owner.components.playercontroller:EnableMapControls(false)
		owner.components.playercontroller:Enable(false)
	end
	UpdateTint(inst)
end

but this is pure guess, and I can't test codes now, so it maybe will not work.

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...