Search Unity

Different Hurt Enemy Hurt Animation

Discussion in 'Animation' started by Doom-Holme, May 25, 2020.

  1. Doom-Holme

    Doom-Holme

    Joined:
    Apr 4, 2020
    Posts:
    3
    Hello ya'll, so as the title already says I want the enemy to have different Hurt animation whenever I slap him. I'm currently creating a game based on the "Something about" series from TerminalMontage if somebody knows who that is. I want my main character to make a meele combo, and the enemy to have different animations reacting to that combo. Also, I'm pretty much a beginner in Unity. If somebody would be willing to help me out when it comes to animations, and how to call them via script, I'd be more than glad. I'd obviously show you the current project and my ideas. I hope ya'll have a nice day, thanks in advance :)

    P.S I also added the first slap cycle where the enemy behaves to it. Mario 1st Slap Cycle.png
     
  2. mugewara

    mugewara

    Joined:
    Feb 13, 2018
    Posts:
    3
    Hello. Btw, nice reference you got there, I love TerminalMontage.

    Lets say we have three hurt animations. They should be on the enemy animation controller. Ok, you should make an int condition and call it something like "hurtAnimation" and assign the conditions to the transitions of the hurt animations in the animation controller. When the enemy is hurt, get a random number, then set the int condition as the result number, like this:

    Code (CSharp):
    1. void enemyHurt() {
    2.    // 1,2 and 3.
    3.    int hurtAnimation = Random.Range(1,4);
    4.    animationController.SetInt("hurtAnimation", hurtAnimation);
    5. }
    This could be improved, but I think this is a good start.
     
  3. Doom-Holme

    Doom-Holme

    Joined:
    Apr 4, 2020
    Posts:
    3
    Hey, thanks for the reply! I really like TerminalMontage aswell. I'm currently doing a personal project about his "Something Series". I posted another thread on Unity Answers about my sprite constantly flipping. Also added a small gif about the problem. The you can see what I'm doing. Would also appreciate if you could help me with the current problem :) But this solution helped alot, thanks again!
    Anyways, have a nice day :_