Jump to content

Way to get name of current animation playing for inst?

Recommended Posts

Hello, I was wondering if there's a function or something like 

inst.AnimState:GetCurrentAnimationName() (not an actual function)

which returns the name of the current animation playing for an inst as a string.


If there's no such code may I recommend Klei devs add such a feature, I do not think it would take too much work and it would allow for some cool new things possibilities for modders to mess around with!

With this information we could easily just play or push the same animation and set the time for any other entity we want. As one of the things we would like to do with this is add a shadow clone effect and add duplicate symbols on entities without editing their animations (such as armor using the entity's head or torso symbols).

Considering we already have IsCurrentAnimation I don't see how this would be hard to implement as it should be a simple modification of that code. Instead of comparing current animation name to our input and returning true we would just return the animation name.

Edited by SuperDavid
Link to comment
Share on other sites

Currently there exists no such function directly.

However, the entity's debug string contains the currently running animation and this is one way on how to parse it out:

function GetCurrentAnimation(input)
    return string.match(input.entity:GetDebugString(), "anim: ([^ ]+) ")

This function may return nil if nothing is found.

  • 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

  • Create New...