Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Animator.SetBool not Working

Discussion in 'Animation' started by CoolCosmos, May 26, 2020.

  1. CoolCosmos

    CoolCosmos

    Joined:
    Nov 21, 2016
    Posts:
    247
    Hi guys,

    It was working properly but somehow broken. I checked everything looks correct. I see the problem is that "toFireRight" bool is not being true.

    I can also see the message of Debug.log on console. Can you help me?


    Code (CSharp):
    1. public class PlayerMovement : MonoBehaviour
    2. {
    3.     public bool isFiring = false;
    4.  
    5.      private void Awake()
    6.      {
    7.           myAnimator = GetComponent<Animator>();
    8.      }
    9.  
    10.     private void Update()
    11.     {
    12.         if (Input.GetKey(KeyCode.Space) && !isFiring)
    13.         {
    14.             myAnimator.SetBool("toFireRight", true);
    15.  
    16.             isFiring = true;
    17.  
    18.             Debug.Log("WORKS");
    19.         }
    20.     }
    21. }
    22.  
     

    Attached Files:

    Last edited: May 26, 2020
    CloudyVR likes this.
  2. unity_PwXfMGmzHmDcsw

    unity_PwXfMGmzHmDcsw

    Joined:
    Jul 7, 2019
    Posts:
    6
    Same issue here