Monday, May 20, 2013

Realtime movement is a pain to keep track of

Today I was working AI of the enemies and I have several flags assigned to the player class. Every non-map object is a player and the tileType is keyed off to get see what tile it is. For example,

2 = Player
3 = enemy
4 = open
5 = Point of Interest
player = Player(id,tileType,isActive,target,path,pathCount)

The AI checks if the tileType is an enemy and then checks if the the distance to the player is <= the activation distance. The enemy then calls the astar to the position of the player and returns a list of coordinates. This path is assigned to the player.Path list and is updated every enemy clock cycle, currently 2 seconds(enemy speed). When the player/enemy moves path count is updated and the character moves closer to the target. When the target is reached the list is removed. A few bugs not withstanding it works. But when the player moves the enemy AI does not adjust to the new player location. I do not want the enemy to poll the player position every draw call and it would be good to update the pathfinding when an enemy is moved.

I will post a video when I get something working.

No comments:

Post a Comment