Character AI for fightscene

Hi there,

I am trying to create a scene in my game where you fight a big monster. I want the monster to use random moves against you such as a standard attack (sword swipe) and a special move (tail swing). It would also be good if he would get within range to attack so that he could make contact with you instead of just swiping in your direction even if you are 10 meters away.

I really havn't got a clue of how i will achieve this so any help would be very appreciated.

I am also interested in having a trigger activate once the boss has got to a certain percentage of health - though that might be best answered if i make a new question.

Thanks!

Hmm it seems to me what you need is a coroutine and some animation events. thats the easiest way to do this.

just call a function like this once

var WaitTime:int=10 // betweenattacks

function monsterAttack(){
 while (true){
  do_attack(1);
  yield waitforseconds(WaitTime);
  do_attack(2);
  yield waitforseconds(WaitTime);
  do_attack(3);
  yield waitforseconds(WaitTime);
 }
}

in the function do_attack(attack) simply activate the animation that corresponds to that attack you can attach an animation event to the attack animation frame you'd like and assign how much damage it makes (if the character is not blocking)

For the AI apply a series of conditions for each attack per example check the distance of the hero, or how much health he (she) has, to use attack 1 , 2 or 3 to check the distance, simply create a vector between the AI character and the player and check its magnitude.

Per example

    while (true){
    var distance:Vector3=(Player1.transform.position-Enemy.transform.position);
var dis:float=distance.magnitude;
    if (dis<100) do_attack(1) else do_attack(2);
    yield waitForSeconds(WaitTime);
    }