B.A.M. is a sci-fi strategy action game I and my team are developing for our Advanced Production class at Chico State. I am one of three Programmers in our 14 person team. This post details my work process across our first Sprint.
 |
| Enemy Targets Building |
For this Sprint, my work consisted of the fundamental enemy AI. I have very little experience with Unreal Engine, so I've been a little slow with my work so far, but I've really been learning a lot. To start, I made a base enemy as a Character and dove into Behavior Trees for the first time. The enemy really has two main behaviors: attacking the nearest building and retaliating against the player when it's attacked. Currently, the attack and movement are both templates to be filled with the proper mechanics.
 |
Enemy Targets Player
|
 |
Base Enemy Behavior Tree
|
 |
| Enemy Object Pooling |
Once I got the enemy prioritization and movement done, I moved onto getting it to spawn in the world. For this, I implemented an object pooling system for sake of optimization. However, this object pool gave me a bit of a headache because of the way my enemies were functioning as characters. I ran into issues with the behavior tree using old data when an enemy was activated and how to turn off and restart that AI Controller logic. Ultimately, I did get it working in the end and learned a lot more about Characters and Controllers in Unreal. The enemy spawns within a random interval of 10-12 seconds.
 |
In-Level Spawn Locations
|
 |
Weighted Spawn Locations
|
As part of the enemy spawning, we wanted in-level placeable spawn locations where enemies will spawn one-at-a-time at randomly. These locations also are weighted by how many buildings are nearby - enemies are more likely spawn at a location with more buildings nearby to attack. This weighting took me a decent amount of time figuring out how to do it. As it stands now, every location has a default weight of 1, and gets an additional +1 weight for every building within the acceptable radius nearby. Locations are then picked with a random number up to the total of all weights, ie: two spawn locations with weights of 5 and 4 means a random number up to 9 is generated, if it's 5 or below the first location is picked and if it's 9 or below (after checking the first one) the second location is picked. The default weights and acceptable radii are all instance editable, so each location can be tuned after it's put in the level. This weighting system is also planned to be expanded to take into consideration different locations being more likely to spawn one enemy type over another, or for different buildings to be more important and give nearby spawn locations more weight.
 |
| In-Editor Debug of Spawn Location Building Detection Range |
Comments
Post a Comment