Hi there, I have created a door that the player has to hack in order to open it. It works fine.
The problem I am having is that when I copy the door as I want quite a few hacking door in my game. The UI Progress bar stops working…
I will post links to my blueprints and also a video of the problem I am having so you can see.
Video of door not working - Eroor door - YouTube
Hack Door Blueprint - Hack Timer posted by Naate | blueprintUE | PasteBin For Unreal Engine 4
Hack Timer Function - HackProgress Timer Function posted by Naate | blueprintUE | PasteBin For Unreal Engine 4
Progress Bar BP - Hack Progress Bar UI posted by Naate | blueprintUE | PasteBin For Unreal Engine 4
It is caused by the incorrect use of Get All Actor of Class - you call a loop and it terminates after the first iteration.
If you want to hack multiple doors at the same time, give each door actor a separate widget - the door actor could be the one responsible for creating and storing widget reference here - that’d be the most logical approach.
If you ever going to hack only 1 door at a time, have the widget created and referenced in the player character and either use an interface (if there are more hackable classes) or just directly communicate with the door via a trace / overlap - whatever you currently use to talk to the door actor.
Generally speaking - as a beginner - in 99% of the cases, if you feel the need to use Get All nodes, your approach is most likely incorrect.
Just made this yesterday I think it will solve all those problems for you and clean up a bunch of your code. Just add this actor component to any of your doors and simply call the main function “Update Bar” on any door and it will do the rest for you. Enjoy
You may also like this just for effect…