Adding health to the AI
In this part of the project, you will add a health system to the minion AI to make it possible to defeat it during gameplay. You will also add a spawn system so that when the opponent is defeated, the player will be rewarded with a well-deserved prize.
To implement such features, we need to open the minion class and start doing some coding – open the US_Minion.h
header, and in the private
section, add these two declarations:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Health", meta = (AllowPrivateAccess = "true")) float Health = 5.f; UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Pickup", meta = (AllowPrivateAccess = "true")) TSubclassOf<class AUS_BasePickup> SpawnedPickup;
The first one is used to keep track of the enemy health, while the second one will contain the class of the item pickup that will be spawned once the minion is defeated. Both of them can be modified in a...