Search Unity

Animation works in animator but not in game

Discussion in 'Animation' started by sickprogrammer, Feb 18, 2018.

  1. sickprogrammer

    sickprogrammer

    Joined:
    Feb 18, 2018
    Posts:
    1
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    I don't know code but if I had to bet I would put money on something being incorrect in the line below // Reload.
     
  3. StickyHoneybuns

    StickyHoneybuns

    Joined:
    Jan 16, 2018
    Posts:
    207
    Well, your code checks for if the user is pressing R and if cartouches == 0; Both of these statements have to be true. I see no reference to Tir so I assume it is a script attached directly to that gameObject? If Tir is a script on another gameObject you will need to reference it first.

    Open up the animatorController and view the parameter reloading. If it never sets true then you know the if statement is never being entered

    Also, just post your code directly to here using insert>code from the toolbar at the top. Makes the discussion flow much easier.

    Edit again: It's also best practices to cache your getComponent calls in the start of a function like you did with Animator.
     
    theANMATOR2b likes this.
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    I was going to mention this - but was a little unsure of my own knowledge. :confused: