Author Topic: Hammerwatch enemy AI  (Read 7204 times)

Anu8is

  • Posts: 4
  • Maggot Crusher.
    • View Profile
Hammerwatch enemy AI
« on: June 14, 2014, 10:41:26 AM »
Hi guys(and especially developers  ;D)! I make some game project, and try to do some fast enemy AI, which pursues player. Aaaaand i want to ask - how enemy AI work in Hammerwatch?
P.S.: sorry for my spelling, english not my native language.  :-X

Hipshot

  • Developer
  • Posts: 455
  • Level Designer
    • View Profile
Re: Hammerwatch enemy AI
« Reply #1 on: June 14, 2014, 01:03:15 PM »
Hi!

What more specific do you want it  to do, except for just following a player? Cause that would be very simple, like in the video below.

<a href="http://www.youtube.com/watch?v=dhFxWDsfh9c" target="_blank">http://www.youtube.com/watch?v=dhFxWDsfh9c</a>

Anu8is

  • Posts: 4
  • Maggot Crusher.
    • View Profile
Re: Hammerwatch enemy AI
« Reply #2 on: June 14, 2014, 01:15:17 PM »
Well , what it do depends on type of an enemy: some must shoot, others wait in ambush. But first of all they must move correctly, don't stuck in the wall and etc. And because i wanna know - what kind of algorithm they use?  :D

Myran

  • Developer
  • Posts: 183
    • View Profile
Re: Hammerwatch enemy AI
« Reply #3 on: June 14, 2014, 03:37:47 PM »
You're making your own game? The enemies in Hammerwatch use a very simple A* pathfinding with no fancy features at all, it shouldn't be hard to do something similar.

Anu8is

  • Posts: 4
  • Maggot Crusher.
    • View Profile
Re: Hammerwatch enemy AI
« Reply #4 on: June 14, 2014, 04:07:30 PM »
Got it. Yes I do my own game. A have some trouble with algorithm which I use. It tracking player on it previous position and its working very well, but sometimes its start bug.  :-\ For example he starting move around 2 point in endless cycle) I thought that  use only A* working slowly for big count of enemy, but if your game using it without lag, its a very impressive. I wanna try to combine my algorithm with A* and now sure that its good idea. Thanks again.  ;D

Myran

  • Developer
  • Posts: 183
    • View Profile
Re: Hammerwatch enemy AI
« Reply #5 on: June 14, 2014, 06:02:12 PM »
Yeah, the performance of A* hasn't really been an issue for us, we just make sure not to pathfind until the target has moved a significant amount, and we also only pathfind for enemies that are somewhat close anyway.

DivinityArcane

  • Posts: 30
  • wat
    • View Profile
    • DeviantART profile
Re: Hammerwatch enemy AI
« Reply #6 on: June 28, 2014, 01:13:46 AM »
Going to second that A* is _not_ good for large applications normally, but if you add distance requirements, it's fine. You never really want to be path-finding to a player when you're not on-screen, anyway (short of some exceptions like maybe bosses.)

Keep in mind that you also want to do checks to see if path-finding is even needed. For example, ranged enemies should first check whether or not they're in range to attack first, and if so, attack the player. If they aren't in range, take the steps needed to become in range (or be in a spot with no obstructions) It's easier to explain than implement sometimes, but there's a lot of information on the internet about the best ways to do this.

Myran

  • Developer
  • Posts: 183
    • View Profile
Re: Hammerwatch enemy AI
« Reply #7 on: June 28, 2014, 01:20:45 AM »
Yeah, we also do pathfinding in a separate thread and have a cooldown for pathfinding for every enemy so that they don't do it too often.