Search Unity

Question SetTrigger not working, but only for one character

Discussion in 'Animation' started by RobDcomedy, Sep 21, 2020.

  1. RobDcomedy

    RobDcomedy

    Joined:
    May 19, 2019
    Posts:
    5
    I know this topic has been posted before but I was unable to find an answer to the issue I'm having, and I have come to a dead-end on all the reasons I can think of why this isn't working.

    In short: I am working on a game with 9 playable characters. 8 of them, the animations are working perfectly.
    I have an initial "Player" script, and those 9 players all have a subclass script of Player.
    I am triggering the animation this way - Checking for mana, and if successful, triggering "isCasting" Trigger parameter in the Animator.

    From the "Player" Script

    public virtual bool CastSpell(Spell spell, Player targetCharacter)
    {
    bool successful = playerMana >= spell.manaCost;
    if (successful)
    {
    GetComponent<Animator>().SetTrigger("isCasting");

    // and so on...

    This successfully triggers the animation in 8 of my 9 characters. All the other animations trigger successfully (Melee, Block, Die, etc) in basically this same fashion, it's just the Casting Trigger that doesn't work for this player one player only. It's driving me nuts.

    A few things:
    1) Yes, the method is virtual, but in this Player's case there is no override, so it is not working off another method. (and other Players set up this way also work fine)
    2) I checked the spelling of the trigger itself in the Animator Window was correct, "isCasting"
    3) I checked to make sure the animation was transitioning between Idle and Casting correctly. (no exit time, correct parameters, no extra triggers or bools attached by accident, etc). However watching it in real time the animator does NOT transition when it should be triggered, so it would seem it is never triggered in the first place.
    4) When in play mode, I can MANUALLY click the trigger in the Animator and it works fine.
    5) I get absolutely no errors in the console when casting with this character that would lead me to think there is an issue with the code itself.

    So I believe I hit a dead end. I can't figure out why this would work for 8 characters out of 9, but not the 9th, when they are all set up in the same way in the animator and are working off the same Player script Method.

    Appreciate any help.
     
    Last edited: Sep 21, 2020