HybridIdleState.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Animancer // https://kybernetik.com.au/animancer // Copyright 2022 Kybernetik //
  2. using Animancer.Examples.StateMachines;
  3. using UnityEngine;
  4. namespace Animancer.Examples.AnimatorControllers
  5. {
  6. /// <summary>A <see cref="CharacterState"/> which plays an animation.</summary>
  7. ///
  8. /// <remarks>
  9. /// This class is very similar to <see cref="IdleState"/>, except that it plays the animation inside an Animator
  10. /// Controller instead of as a Transition.
  11. /// </remarks>
  12. ///
  13. /// <example><see href="https://kybernetik.com.au/animancer/docs/examples/animator-controllers/character">Hybrid Character</see></example>
  14. ///
  15. /// https://kybernetik.com.au/animancer/api/Animancer.Examples.AnimatorControllers/HybridIdleState
  16. ///
  17. [AddComponentMenu(Strings.ExamplesMenuPrefix + "Hybrid - Idle State")]
  18. [HelpURL(Strings.DocsURLs.ExampleAPIDocumentation + nameof(AnimatorControllers) + "/" + nameof(HybridIdleState))]
  19. public sealed class HybridIdleState : CharacterState
  20. {
  21. /************************************************************************************************************************/
  22. /// <summary>
  23. /// Normally the <see cref="Character"/> class would have a reference to the specific type of
  24. /// <see cref="AnimancerComponent"/> we want, but for the sake of reusing code from the earlier example, we
  25. /// just use a type cast here.
  26. /// </summary>
  27. private HybridAnimancerComponent HybridAnimancer
  28. => (HybridAnimancerComponent)Character.Animancer;
  29. /************************************************************************************************************************/
  30. private void OnEnable()
  31. {
  32. HybridAnimancer.PlayController();
  33. HybridAnimancer.SetBool(Animations.IsMoving, false);
  34. }
  35. /************************************************************************************************************************/
  36. }
  37. }