I am changing the anim sequence acording to the distance between enemy character and main(third person) character using entityDistance.
PointEntity(badguy, player,3,1.0)
If stopanim2 = False
If EntityDistance(jane,bg_pos) < 15.0
bg_framebegin = 77
bg_frameend = 115
animate_badguy() ' badguy walk
UpdateController(bg_control,badguy.rotation.y,1.6,0, 0,1,100,0)
EndIf
EndIf
If EntityDistance(jane,badguy) <= 3.0
pointEntity(badguy,jane)
jane_framebegin = 924 ' jane attack
jane_frameend = 1031 animate_jane()
bg_framebegin = 291
animate_jane()
bg_frameend = 411
animate_badguy() 'badguy attack
bg_health = bg_health - 0.1
EndIf
If bg_health <= 1 Then kill_badguy()
EndIf