Search Unity

AI looking at player problem

Discussion in 'Animation' started by Kaloyan13Tanev, Mar 9, 2022.

  1. Kaloyan13Tanev

    Kaloyan13Tanev

    Joined:
    Sep 5, 2021
    Posts:
    1
    Hello, I am making an ai knight which must follow a wizard and play an attack animation when close enough. However I want the knight to look up and down with the attack anim depending on the place where the wizard is, but when the sword swings for an attack at some point the rotation (for looking up and down) should lock so it doesn't move and swing at the same time (as it is impossible irl and there should be a way to dodge the attack). I activate a script with animation events which tells the spine bone of the knight to follow the wizard and then i turn it off again with animation events. I tried to make a script saving the rotation, but as soon as I turn the script off the rotation goes to standard looking forward. So here are my scripts. I will really appreciate your help as i'm doing this game for a kind of competition and I'm running out of time. Oh, also tell me if you need additional info or a clearer explanation about something