Jump to content

Execute code when stepping?


Recommended Posts

Is there an event or something I can hook into to execute code on my character when I footstep? I want to give my character a "heavy" footstep during a certain scenario. I feel like I've seen something like

ent:ListenForEvent("step", AwesomeFunction) -- This is written off the top of my head and isn't taken from anything

but I can't find any evidence of this existing in the game, and it doesn't seem to work, so maybe I was imagining things.

Link to comment
Share on other sites

Actual footsteps I believe are called in the stategraphs, however I believe if you just want to make your character play something when you move? Then you can just listenforevent("locomote")

If you want something more precise like when the character actually excutes the footstep sounds, then you'll need to hook into that specific function in the stategraphs which is a lot harder and likely requires upvalues for a local function.

  • Like 1
Link to comment
Share on other sites

8 hours ago, IronHunter said:

Actual footsteps I believe are called in the stategraphs, however I believe if you just want to make your character play something when you move? Then you can just listenforevent("locomote")

If you want something more precise like when the character actually excutes the footstep sounds, then you'll need to hook into that specific function in the stategraphs which is a lot harder and likely requires upvalues for a local function.

Okay, if I wanted to save myself some nights of trying to learn how states work and stuff, would it be viable to use doTaskInTime to sync with the footsteps of my character?

Link to comment
Share on other sites

7 hours ago, TheSkylarr said:

Okay, if I wanted to save myself some nights of trying to learn how states work and stuff, would it be viable to use doTaskInTime to sync with the footsteps of my character?

It really depends what it is you are trying to do...if you want to do something that for some reason has to play when the footsteps sounds play. Then you'll need to sync it with that. Otherwise if all you want to do is do something when you move then you can simply do a periodictask and check for movement or listenforevent("locomote")

  • Like 1
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...