How to create a basic health bar using C++?
Hi I am trying to build a game in C++. But, I am having trouble finding a video tutorial. Can someone tell me how to create a basic health bar using C++? Also, some info on how to damage the player with a fire would be helpful.
asked Apr 17 '19 at 02:18 AM in C++ Programming
Creating a health bar purely in C++ makes little sense what i would suggest to you is create your health system entirly in C++ add some assignable MulticastDelegate on change to the health system and create a health bar widget in the editor which you can attach to the hud which registers itself to that health system and on change shows the current state.
For the delegate I would suggest something like that: DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnHealthChanged, float, currentHealthInPercent, float, oldHealthInPercent);
and as member variable: UPROPERTY(BlueprintAssignable) FOnHealthChanged OnHealthChanged;
To damage a player with fire I would use an overlap volume and while the fire is burning and the player is inside this volume you apply damage to the player.
there are callbacks to OnComponentBeginOverlap OnComponentEndOverlap to find out when a player enters, leaves a volume.
answered Apr 17 '19 at 06:07 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here