- Home /
Third Person Controller Custom Characterstates
I can't find the answer to this question specifically anywhere. I can see similar ones about replacing the Run Walk Trot animations with their own, but what I need is more complicated than that.
I have enum CharacterState set up with different animation states like Sitting, Crouching, etc. I can get the animation to play, but in the Inspector it shows the CharacterState as Walking instead of the name of the animation I've input.
if (Input.GetKeyDown ("q"))
{
_characterState = CharacterState.Crouch;
}
if (_characterState == CharacterState.Crouch)
{
if (this.isControllable)
{
_animation.CrossFade(crouchAnimation.name);
}
}
Sorry for the way I copypasted this. It looks a little weird.
But this is a sample of the code I have. It works the same way that the others do, and it shows the animation, but the CharacterState still says Walking.
Is there a way to make a constructor that says if (crouchanimation.IsPlaying) _characterState does not equal CharacterState Walking ?
I couldn't find the proper way to type that without getting errors, so either an answer for how to properly code that, or a different way to put your own animation States inside ThirdPersonController would be nice. Also this is C#.
is _animation a $$anonymous$$ecanim "Animator" or an "Animation" component?
Either way you should use the $$anonymous$$echanim and assign the states with variables, not directly with crossfade!
It is not $$anonymous$$ecanim, it is the animation component, and it seems to work fine for all of the other states- so why wouldn't that work for this one? $$anonymous$$aybe be more specific?
The script probably sets the _characterState to walking the next frame. $$anonymous$$ake it check if the character isn't Crouching before it sets any states in the script.
I was suggesting changing over to the $$anonymous$$ecanim system, I personally find it much more intuitive.
Your answer
![](https://koobas.hobune.stream/wayback/20220613181846im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
ThirdPersonController Script doesn't use animations on model imported from Blender 1 Answer
Is there a way to edit the default 3rd person controller to do extra animations? 0 Answers
Animation Only Plays Once in third person controller 0 Answers
Changing default animation of AI third person controller to walk? 0 Answers
Can the animation editor create local rotational data? 3 Answers