Announcement

Collapse
No announcement yet.

Health Item disabling Health Regen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Health Item disabling Health Regen

    I have this system which updates my health as a "regen"Click image for larger version

Name:	Screen Shot 2017-01-19 at 8.35.22 AM.png
Views:	1
Size:	557.0 KB
ID:	1207839
    but it stops working when i hit my health item, it gives the person health, but it stops the regen/updating healthClick image for larger version

Name:	Screen Shot 2017-01-19 at 8.40.06 AM.png
Views:	1
Size:	202.2 KB
ID:	1207840
    Click image for larger version

Name:	Screen Shot 2017-01-19 at 8.40.43 AM.png
Views:	1
Size:	184.8 KB
ID:	1207841 this is connected to a event hit
    thanks for any help let me know if you need anything more to help me

    #2
    Hey,

    the first image is the "UpdateHealth" function?

    Is that called on tick?

    Is "HealthIncrease" meant to heal the person? Because then you should make sure that the Health is not going over MaxHealth.
    You can use a MIN node and use Health + 1 for the first input and "MaxHealth" for the second input and use the result to set your Health variable.
    Then you can be sure that it doesn't go over MaxHealth.

    Also why is "HealthIncrease" calling "UpdateHealth"? Isn't UpdateHealth getting called on tick anyway? I mean, you are using the WorldDeltaSeconds, so I assume it's called on tick.
    And the last screenshot, where is that called? Where does the branch come from?

    In addition, why are you setting the percentage of the Widget twice in the first screenshot?

    In the first Screenshot you should change the logic to this:

    if Health < MaxHealth -> Use the HealthReg code and if Health >= MaxHealth then set Health equal MaxHealth. Otherwise you'll end up with Health being greater than MaxHealth.

    It's hard to see why it breaks but I assume it should work like this:


    OnEventTick -> UpdateHealth -> SEQUENCE NODE: FirstExec -> "Health < MaxHealth?" Yes -> Set Health = "Health + HealthReg * DeltaSeconds"
    -------------------------------------------------------------------------------------------------->No -> Set Health = MaxHealth
    -----------------------------------> SEQUENCE NODE: SecondExec -> Set the Widget Percentage = Health/MaxHealth

    Why the SequenceNode? Because you always want to update the widget and not only if the Health is < MaxHealth.

    Now, you use a HealthPotion (no idea how you do that in your code, but I assume it just happens) and this should happen:

    HealthPotionUsed -> Set Health = "MIN(Health + 1, MaxHealth)"

    And that's it.
    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

    Comment


      #3
      In addition to what eXi said, please don't use the display name to identify what item(?) is used.

      At first the display name is not guaranteed to be (or actually most likely it won't be) the same in editor builds and in packaged builds. In the current editor version this may not result in bugs but Epic may change this already with the next update. So this should already be enough reason not to use this.

      If anything use GetObjectName but even that would be a really bad solution. You're binding the name of a class to its functionality. What if you decide to change the name? This would lead to really strange bugs. That's the kind of software design you really should avoid no matter if you're working alone or in a team.
      Twitter | Multiplayer TopDown Survival Kit | Fog of War | Game Stats Kit

      Comment


        #4
        To expand on what Pepeeee said instead of checking the "display name" of the actor, you'd want to cast. Actor -> Cast to HealthPotionBlueprintClass -> If true, you know it's your health potion!
        Columbus Ohio Unreal Meetup
        @OCGameStudio | Sphere Complex | twitch.tv/WFMOz

        Comment

        Working...
        X