Forum rules - please read before posting.

Animations - What's the best way to cycle between multiple idle animations?

edited August 2020 in Technical Q&A

Unity Ver: 2019.4.5f1
AC Ver: 1.71.8

Howdy,

I'm just starting to dig into how AC does animation on characters. I think I've got the basics from the manual and playing around to understand the relationship between the animator setup and the NPC component.

What I'm seeing though seems to be restricted to a single idle animation. In my case, I've got several idle animations I'd like to (perhaps randomly) cycle between on the character.

What would be the best way to achieving this?

Comments

  • Facing only one direction?

    You can use the Character: Animate Action to change a character's standard animations, but the exact method depends on their Animation engine.

    With "Sprites Unity", this is done by changing the "Idle name" field in the Action to something else, e.g. "CrouchingIdle".

    With "Sprites Unity Complex", AC animates characters only by changing Animator parameter values - not by playing animation clips directly by name. What these parameters (e.g. a "Move speed" float) actually control is then down to you - so you can introduce another parameter that causes a different Idle animation to play when the move speed is zero.

    I'd recommend this latter method in general whenever you want to animate a character in a custom way - and it's more in line with Unity best practices besides.

  • edited August 2020

    Think we're in business! Took me most of the morning to get a Sprites Unity Complex setup up and running but you can see the character is now cycling through different idles and will change to a talking animation based on a bool state change.

    Ran into a bit of a problem where Unity was complaining about a missing parameter called 'Direction'. I can't see anything called this setup in the NPC inspector but adding it to the animator seemed to make Unity happy

  • Is that to be expected Chris if the animator doesn't have a direction parameter? I was using your Brain2D_SpritesUnityComplex prefab as an example but that doesn't seem to have any direction parameter on it:

  • It should be listed in your character's list of mecanim parameters under Direction integer.

    It may be a bug - this field will only show if Facing directions is not set to None, though it looks like it'll still have an effect in-game regardless.

    I'll attempt a recreation, but in the meantime try enabling Facing directions, removing the direction integer parameter, and then setting things back to None.

  • edited August 2020

    Hey Chris,

    Gave it a go but it always demands a direction parameter even if set to none.

  • Set it to None afterwards - first set it to eg Four, then clear the "Direction int" parameter that then becomes exposed.

  • Ah, yes! Sorry Chris, totally misread your fix. Yep. Doing that sorts it out.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.