Hi all. I’m new to UE4 in general and wanted to share this coin collection blueprint I put together. My goal is to recreate systems from other games, in this case the gold collection system from Sekiro. Hope I can get some feedback and how it can be improved. Cool…so here we go:
- Started by creating the float animation and event to trigger, in my case when player presses Q.
- Since Q is set up for multiple uses, I needed to add some kind of delay, so when Q is pressed, I used a timeline as a delay since I can stop it if player releases before 1 second and start it over again for every press. After 1 second, Sequence 0 checks if player is withing a certain radius of self to activate (in theory this is also allows the use of equipment that boosts pickup range).
The next best option I found for the distance check is to have a large collision sphere that overlaps and opens a gate, BUT found it not to be reliable when multiple items spawn close to the player (could not figure out why, my guess is that it doesn’t always trigger the Begin Overlap). So resorted to every item that has spawned having to check the distance to player once when the button is pressed for 1 second.
- If player is withing range: do stuff, in this case set material is for visual debugging. A bool variable is set to true, this will see in next step. The TravelToPlayer timeline is used to move the BP to players location updating in real time, basically makes it like a homing missile; what’s cool about using timelines is that I can “ease in” at the start of the tracking and accelerate as it reaches the player.
- Finally, when it reaches the player, it checks the bool we turned true, if false does not allow the player to destroy the item withot pressing the button. I want to force the press for 1 second for this actions specifically, so when 1 second has passed, the item is allowed to “get picked up” and when the BP hits the player, it calls the dispatcher responsible for adding X item, coin, money, etc. Then destroys.
Before usin a bool as a “gate”, I had an actual gate node, but it would open for all instance of the BP allowing the item to be picked up by walking over. The bool gave me the option to keep each instance independent.
My only concern would be having a large amount of items to collect checking player distance at the same time. Since this will be dropped by a limited number of enemies and cannot be spammed because of the 1 second wait to activate, guess it will not be a problem. The BP is created with a tag so all instances will be destroyed when player leaves the area.
This is fairly simple but I’m proud that it works lol. Wanted to share in hope of improving the system and maybe help someone else learn as I am learning.
Thanks if you’ve made it this far!
Here is the entire system for reference: