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