Jump to content

Recommended Posts

Hello! o/

So i tried this, and worked fine:

Spoiler

local function sayOnIdle(sg)
    local old_onenter = sg.states["idle"]["onenter"]
    
    sg.states["idle"]["onenter"] = function(inst, pushanim)
        old_onenter(inst, pushanim)
        GLOBAL.TheNet:Say("IDLE",true)
    end
end

AddStategraphPostInit("wilson_client", sayOnIdle)

It triggers when the player's state is "idle".

But then when I disable EnableMovementPrediction It doesn't trigger anymore. 

Is there a way to make it work with EnableMovementPrediction disabled?

Thanks :3

Edited by sinideas

Ah, I had a problem like this myself just the other week!

As I recently found out, with MovementPrediction disabled, clients don't have access to their own stategraphs or buffered actions. Kinda sucks. So how did I fix it?   I didn't ¯\_(ツ)_/¯

BUT! I found a different way of doing it. Instead of listening for the player's state, you can listen for the player's current animation! It's a little inefficient, since I have to run it on every frame, but it gets the job done.

if inst.AnimState:IsCurrentAnimation("idle_loop") then
	old_onenter(inst, pushanim)
    GLOBAL.TheNet:Say("IDLE",true)
end

It might be a little more difficult for your case, since there is more than one idle animation to check for (idle_sanity_loop, idle_shiver_loop, etc) And if you only want it to only run once as opposed to running on every frame of the player's idle animation, you'll have to set something up some variables to disable it from running after it sees the idle_loop animation once, and then re-enable it again once it sees them using any other animation.

But if that didn't make any sense, I can give you some more example code

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