Search Unity

Add Behavior to Animation State

Discussion in 'Animation' started by daspratik96, Feb 1, 2021.

  1. daspratik96

    daspratik96

    Joined:
    Aug 6, 2020
    Posts:
    1
    Hi everyone, I'm completely new to Unity and have been stuck at one thing for a long time.
    I'm trying to make this one scene in FPS, where my enemy has 3 states, dodge, attack(attack + dodge) and hit.

    I have made a weapon as the child of the enemy. The enemy should throw this weapon at the FPS camera, once his state changes from dodge to attack + dodge and once dodge + attack animation is ending (and as dodge is beginning to play again), I want the weapon to again become the child of the enemy ( kind of like God of War Axe throw, //youtu.be/M-3P59GtRW4 ). Also I want the animations to be random, let's say if he starts with dodging for first 5 seconds then he's attacking for 3 seconds then dodge anywhere between 5-10 seconds then attack (he can attack only thrice in total after which he just dodges). For the hit state, if player weapon hits the collider of the enemy then enemy is captured. If the player is idle for 5 seconds then enemy starts attacking.

    The only thing I've thought till now is adding a script to enemy's weapon (along with enemy )then switch between my state parameters there but since I'm not familiar with state machine behaviors, I'm having an issue to set the code for this concept.

    I've attached my animator controller with parameters, any help regarding this is extremely appreciated. Thanks :)
     

    Attached Files: