Sunday, August 29, 2010

They Liiiiive!... Sorta

So I'm a bit late on this post, but here we are. The beginning of the AI is done, with a few bugs. No video right now but will probably be added later.


The Main AI

The EnemyController class will be the main driver of the enemy's AI. It will have all the major logic, state variables, and ranges.


The state variables are the same at the players, and include idle, moving, attacking, and alive (which was added to the player class as well). The same attack variables are used to control when to attack and the attack range boxes as the player. The only difference is what triggers them. The player needs input in order to attack, but the enemy will only attack when the player is at attackRange or less. There is a bug that when the person enters the range it will do the full combo even if the player moves out the range, but will be resolved sometime. Attributes and animation are handled just like the player's character.


Other ranges are used to control when to follow the player and when to stop approach. These are viewDistance and stopMovingDistance respectively. If the player is between these values, the enemy moves to the player.


What determines the direction to move is the Compass class. At this time, it only determines the direction to move. It always watches the player's transform object to determine distance and direction if within range. It will later evolve to check to see if the enemy can truly "see" the player using a "head point" and will determine if they can walk to them via a "foot point". Raycasting is the current idea, but will do some further research to be sure that this is the best way.


What's Up Next

Further revising to the Compass class is up next. When finished, the enemy should be able to "see" a player, and then move to it if possible. If not, it will stand and wait until it can. This shouldn't be needed unless we use gates or other major obstacles.

No comments:

Post a Comment