x

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"

After defeating an enemy, their health becomes the players health

The best way to explain this will be to give an example. You the player starts the game with 10 health. You come across an enemy with 15 health. When you defeat him your health will be 15 health now and the same would be for if you defeated an enemy with a health of 5, your health would become 5 health.

alt textI've included a couple of BP screenshots, hopefully they are of use.

Any help on this would be great. Thanks!

alt text

Product Version: UE 4.16
Tags:
my_character.png (298.8 kB)
enemybp.png (523.3 kB)
more ▼

asked Aug 09 '17 at 05:47 PM in Blueprint Scripting

avatar image

Noose.
1 1 5 5

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

2 answers: sort voted first

I believe I came up with the answer. It seems to be a very simple way and I'm not sure if this is what you meant Ben, but I appreciate the help and it gave me motivation to figure it out, seeing that others were putting there time into helping.

I did this in the enemy BP so I can cast to the player and it should be easy to put it into other enemy BPs so I can easily change the variables that are cast to the player after the enemy is defeated.

I'm going to post my screenshot of what I came up with, so any feed back would be greatly appreciated. Just so I can get an idea if this is the right way of going about what I meant to accomplish.alt text

more ▼

answered Aug 10 '17 at 08:14 PM

avatar image

Noose.
1 1 5 5

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

On your base class for players add a function called, UsurpLife, give it an integer parameter. When this function is called, make sure the parameter Life is over 0, then add that number to your character's current, and max health.

When you receive the attack in your On Component Overlap, it passes a reference to the actor, cast this to whatever is your base class for players, then store it in a variable LastAttackingPlayer. Then when when you die, check to see if LastAttackingPlayer is valid, if so, then call a function UsurpLife, and pass your max health.

more ▼

answered Aug 09 '17 at 09:48 PM

avatar image

BenVlodgi
2.2k 39 17 52

avatar image Noose. Aug 09 '17 at 11:42 PM

I appreciate the quick response.

Another quick explanation of what I'm going for. I want to pass the enemies health to the players health when the enemy dies. so if you the player has 100 health and you kill an enemy with 50 health you now will have 50 health. If the next enemy you come across has 125 Health and you kill him, you will now have his health which was 125.

Again I apologize if you already read it right and what you posted is the way to do it. I just wasn't sure when you wrote, "Then when YOU die." What that seems like is that I would be passing the health to the enemy when I die.

I'm really new but determined to really learn, so any more explanation would be greatly appreciated.

Thanks again in advance!

avatar image BenVlodgi Aug 10 '17 at 04:00 PM

I do/did understand. :)

You can think about this in two ways:

  • when you kill someone you steal their health

  • when you die, you give whoever killed you, your health.

My solution uses the second line of thinking, the result is the same.

avatar image Noose. Aug 10 '17 at 06:25 PM

I may have to come back to this. It seems it might be a bit over my Knowledge level.

(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