Making it collectable
Now we have a collectables base class, and we have a type of pickup item, which is the golden coin. But if we created an instance of it as a blueprint based on the CoinPickup class, it will not be collected, because there is no code to make the character (the Gladiator class) able to recognize the collectables.
So, inside the Gladiator class, I will be adding one function, OnCollectPickup(), and it will work as follows:
The most important thing is that we'll be using the
GetOverlappingActors()method of the gladiator collider in order to pick up anything that collides with the character right away. However, in order to store the data found, we will need something like a container for it.So, the first thing to be done is creating an array of
ActorcalledCollectedPickups.Then, access the
CapsuleComponentcomponent of theGladiatorCharacterclass (AGladiator) using the wordthisin order to refer to the current instance.By using the array we made as a parameter for the...