Forum rules - please read before posting.

Custom character animation trigger

Not sure if this is the correct place.

I'm fairly new to AC and it's working out great so far. I'm working entirely in 2d right now and I have a character walking around a navmesh and it's working great. What I need to do now is play a certain character animation in a certain area. In this case there's a very narrow part of the navmesh that is the stairs. I need to trigger the character to play a certain animation while he walks down the stairs area and another as he walks up. Not quite sure how I can accomplish this.

Any help would be appreciated, thanks.


  • Basically you create the animation you want as a new clip which is then included in the player's animation controller just like all the other standard walk anims.

    Then you can call a custom animation in a cut scene or any action list whenever you choose.

    To call those animations you need to trigger it somehow but a clickable hotspot to say 'go upstairs' would be enough. This is very similar to the 2D demo exits left and right. 
    Another way is to have a trigger placed in the way of a player's path into a section of the navmesh which otherwise would let the player walk INTO the stair sprite. The player's navigation will make it walk to where the player has clicked but before they can get past the trigger you've placed it will trigger your custom anim.

    If you have a general grasp of AC's systems and Unity's animation tools then you should understand all of this but if there's anything you aren't sure of just ask again.
  • Yes, I understand this. In fact, while waiting for a response I started implementing a solution similar to what you suggest with the trigger. As I have it now, I have a trigger upon entering the stairs. At this point, I have 3 actions for the player. I force it to face a specific direction, I move it to a marker, and I force the custom animation. The result I have now is that the player will indeed face the correct direction and move to the marker, however it will not play the custom animation, but the standard walk animation instead.

    Is there something I'm missing? I've tried it with the trigger on both type Continuous and Enter with the same results.

    Thank you for your help.
  • Welcome to the forum @goblinforgegames.

    We might need to see the ActionList in the question, but a custom animation can't play while the character is walking.  You can, however, change what the character's walk animation actually is.  Using the same Character: Animate Action, change the method to "Set standard", and you should be able to swap your regular walk animation for a "climb up" one.
  • That works beautifully! Thank you kindly.

    This toolkit is amazing, by the way. Worth every penny!

  • I don't know if this is too old or I should start a new thread. But it's the same subject. 

    I have 3d character with a mechanim tree and then from the idle animation transitions to a new idle_crouch animation and from that idle_crouch transitions to walk_crouch animation. I created a bool parameter to control these two, "IsCrouching". 
    But I don't understand how the SetStandard method works. 
    I set the method but then asks me to choose between three basic parameters "movespeed" "talkBool" "turn float" And once you do this, fill in the "new parameter name". 
    I'd like to know how should I use this method because I tried a few different things but nothing happened, the player keeps walking with the standard idle and walk animations. 
  • The "Set Standard" method works by changing what parameters AC will affect.

    Mecanim works by controlling parameters for things like the movement speed ("MoveSpeed" float).  The names of these parameters are set in the chararacter's Inspector.  The Action allows you to change those fields at runtime.  Note that this doesn't change the actual names inside your Animator Controller, but instead tells AC to control different parameters.

    If all you're looking to do is have a different set of "crouching" animations play, this may not even be necessary.  The Character: Animate Action's Change Parameter Value method should be used to change the value of the IsCrouching bool.
  • Hi, thanks. 

    No, the case would be to replace the standard idle and walk animations at runtime. Instead of normal idle and normal walk would be  idle_crouch and walk_crouch so the character can walk through a tube and then go back to normal. 

  • That's what I was getting at, apologies if the wording was poor.

    With Mecanim-based characters, animations are not played by name - but instead by controlling parameters.  The character script itself has no concept of what the "idle", "walk" etc animations are - only that the "Move speed float" parameter should be synced to their movement speed.

    Wire up the Controller such that the IsCrouching bool causes the standing animations to transition to the "Crouching Idle" animation when True, and the reverse when False.  Setting the value of that bool should then be all you need, which you can test at runtime without the need for any Actions by having the Animator window open and changing the parameter values manually.
  • edited January 2019

    Revamping an old thread here but...

    Is there a way to override the direction as well? When my character walks down a stairway the Walk_DR animation plays (because of the direction), but I want Walk_R to play, even though she is moving down and right.

  • Welcome to the community, @SeamanNaranja.

    You can precede the animation/movement Actions with a Character rendering Action that sets the Sprite direction field to Down Right, to lock her to face that direction. You'll need to use the same Action afterwards to release it, however.

  • Worked like a charm! Thank you :smiley:

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.