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"

Getting & Setting Variable from different Class Blueprints

Hello everyone!

I would like to know if it is possible to get & set a float variable in a blueprint (CurrentHP) before "knowing" in which blueprint i want to get/set it?

What i a trying to do is the following: I am building a basic hack n slash game where my player swings a weapon and on each weapon swing i check if the weapon hitbox collides with a "monster" hitbox. I made the whole thing work with one specific monster. But now i wanna use different types of monsters (and blueprint classes). Therefor i did create a parent "monster" class and will have several different monster childs from that parent. In my Player Character Blueprint i check if the weapon collission hit a child of the monster class and if so loop the hit monsters to get damage. The CurrentHP float is saved in the different child classes. Now i would like to know how to set the CurrentHP float variable?


Thanks in advance! I hope i did manage to describe my problem in a understandable way...

Product Version: UE 4.11
2016-05-22.png (552.8 kB)
more ▼

asked May 22 '16 at 06:42 PM in Blueprint Scripting

avatar image

36 5 5 6

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

1 answer: sort voted first

Hey all!

I managed to solve the problem after talking about it with a buddy. I went at it the wrong way around and i am a newb to parent classes (well, to programming and UE4 in general ;) ).

I did not know that all childs inherit the variables from the parent class. So, i set up a "CurrentHP" float in the parent class and also made a custom event there ("GetDamage") which gets triggered in the PlayerCharacter Blueprint. See enclosed Screenshots.

Cuatom Event in Parent Class

Player Character Trigger

Maybe this solution can help someone else with similar problems. If there is a better way to solve the problem, please let me know!

2016-05-22 (3).png (186.4 kB)
2016-05-22 (4).png (399.7 kB)
more ▼

answered May 22 '16 at 07:48 PM

avatar image

36 5 5 6

(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