Screenshot
Screenshot

Anathema – Devlog 2

Anathema Enemy setup

All the enemies will have a base C++ class from which each will be derived from. This base C++ class is made with the Character as base. It then has a FlipBookComponent as its RootComponent, a custom AttributeComponent (ActorComponent), another custom component which handles sprite facing and an UInterface for spawning effects etc. .

In the Editor, a new Blueprint is made deriven from this class for each new enemy that is made. In the editor all the content used by the enemy can be added, in this case all the different flipbooks for all the enemy animations. The flipbooks are added to a custom flipbook component that takes care of which flipbook to play in regards to the direction of movement and the location of the player.

The custom made directional flipbook component can be added to any actor that requires multiple sprite angles and contains logic for swapping sprites based on specific conditions. For example, the enemy projectile uses the exact same component.

The Face Player component will make sure the sprites are always facing the player. In the AttributeComponent, the enemy stats can be set like Health.

In the Enemy Template, for each Tick the enemy location is determined as well as the location of the player. Based on these vectors we can calculate the angle and determine if the enemy is facing left or right. (I do not claim to know the exact calculations here, I had to search the internet and do a lot of debugging ;))

Once we have the angle and direction, we can set the Flipbook.

Am sure this is not the greatest code every written but it works great for what I need and it seems easy to maintain. Its been great fun working on this project a