Search Unity

(solved) Cannot play one animation after the other since the first animation gets triggered again

Discussion in 'Animation' started by joshcamas, Feb 22, 2022.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    Hello, I'm trying to do something along these lines:



    Essentially playing a "Block Start" animation, and if the player finishes blocking during this anim, exit. Otherwise, play a block loop animation until the player finishes blocking.

    Any State -> Block: "If isBlocking = true"
    Block -> Exit: "If isBlocking = false"
    Block -> Block Loop: no conditions, Has Exit Time
    Block -> Exit: "If isBlocking = true".

    The issue is once I enter the block loop animation, it will immediately try to enter the block animation from any state, since "isBlocking = true".

    I tried doing something like adding a behaviour that sets a separate bool "hasPlayedBlockIntro" to true when entering block, then clearing it once block loop is done, and making the transition from Any State require hasPlayedBlockIntro be false. There are two issues with this:
    - I need to be able to cancel during a block, so somehow it needs to clear that bool when that happens
    - Other any states can of course occur at any time, so that can cause the parameter to not be cleared if Block state is left.

    Any thoughts?
     
  2. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    The answer was embarrassingly obvious - just use a trigger to start the first animation, not a bool parameter.