Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Animation runs again even if hitbox is off when the animation runs

Discussion in 'Animation' started by EndrerDeg, Apr 14, 2023.

  1. EndrerDeg

    EndrerDeg

    Joined:
    Dec 9, 2021
    Posts:
    3
    I have made a fighting game in Unity that uses hitboxes so that the character reacts when another character attacks.

    I have a problem when a character1 kicks character2 character1 will run an animation where he falls back. I have made a script where the character1 hitbox turns off when the animation runs.

    if(Player1Layer0.IsTag("Stunned"))
    {
    RB.isKinematic = true;
    BoxCollider.enabled = false;
    CapsuleCollider.enabled = false;
    }
    else
    {
    BoxCollider.enabled = true;
    CapsuleCollider.enabled = true;
    RB.isKinematic = false;
    }

    However, when character2 kicks character1 while his "Stunned" animation runs, he will run the "Stunned" animation again after finishing his previous "Stunned" animation.

    How can I fix this issue?