ios - AI for enemy in SpriteKit -


i have been making game in sprite kit time now. have added enemies , wondering how can control them around map using ai(just in other game).

what want enemy wonder around tmx map, turning corner depending on random number. have tried have run many problems. know of articles me this? have done research. "pathfinding" , "a*" come up, know explanation or sample code on how it. appreciated.

welcome so. let me start saying searching same thing. unfortunately pickings have been kinda weak, @ least found far.

i did find couple of interesting reads:

  1. an article on ghosts behavior of pacman. simple effective.

  2. amit’s game programming information. more general discussion making games.

  3. gamasutra. excellent resources things game design.

  4. designing ai algorithms turn-based strategy games. gamasutra article extremely useful in explaining turn based ai in plain english.

all these useful in own ways , make think. however, nothing have come across provides plain worded explination on bad guy's logic (the pacman article came close). searching amazon game ai books yields bunch of books extremely expensive , read more advanced quantum theory.

i ended deciding on simple approach game. have bad guy decide between 2 possible states. patrol mode , attack mode.

in patrol mode sits idle few seconds, walks left or right until hits wall or other object, runs (same rules walking), climbs , down ladders, , occasional jump. use arc4random() decide next when current action completed. provides random behavior , makes bad guy unpredictable.

attack mode happens when player within x distance of bad guy. bad guy has different set of actions choose from. run towards player, swing sword @ player, jump up, , on. again use random function make bad guy unpredictable. results far have been excellent. bad guy behaves 1 of hard beat 12 year kids playing halo.

the bad guy continue battle until dies, player dies or player runs away , no longer within x distance required attack mode. can of course fine tune bad guy's behavior limiting jumping, time between attacks , on.

hope helps , got creative juices flowing.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -