Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can i create a function that would update a health variable smoothly?

Good evening, I am trying to create a function that would update a health variable depending on a damage value. My problem is that I can't figure out a way to make the variable update smoothly inside a function.

Because we can't use timelines and delays in functions I am stuck, I really want it to be handled in a function to make it simple and also because I would be able to call it multiple times like for example if my player takes a hit of 20points, while the health goes down to "H-20" if he takes another hit, it would update two times to get to H-40 and not take the damage it has already decreased + 20.

If you know a way to do this smooth transition inside a function please explain it to me, that would be really nice.

Thank you, Eresea

Product Version: Not Selected
more ▼

asked Aug 08 '14 at 01:26 AM in Blueprint Scripting

avatar image

49 15 21 29

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Use two functions perhaps?

One function does the actual updation of health from current health to target health. This is called in every tick. Use a FInterpTo node or update the health value manually based on Delta Seconds. Lets call it UpdateHealth.

The second function is called with a target health as param, which sets the value of TargetHealth. This is called only once. Lets call it SetTargetHealth.

so say, your characters current health is 100. But he takes a damage of 40. You will call the second function SetTargetHealth(60). And thats it. The actual interpolation will be done by the UpdateHealth function over time.

more ▼

answered Aug 08 '14 at 02:59 AM

avatar image

3.4k 154 51 271

avatar image Eresea Aug 08 '14 at 01:47 PM

Thank you, you were right the two functions did the trick !

Thank you so much for helping me !

avatar image mindfane Aug 08 '14 at 03:38 PM

Glad to be of help :) If the issue is solved, don't forget to mark the thread as solved

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question