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"

Access to variables in a widget blueprint

Hello everyone,

I've run into a problem that I can't get my head around. Base is the top down game template and the topic is about UMG widget blueprints. I'm currently trying to do the following: Whenever I hover my mouse cursor over a test-NPC, the NPC shall become highlighted (via an emissive fresnel material) and a very big, easy to see healthbar (a progress bar) right on top of the screen, exactly like in Diablo or Sacred. Now here's the problem: The highlighting itself works just fine - there's a nice emissive glow around my dummy character and his healthbar is popping up on the top middle of the screen, right where I want it to be. But I can't get the progress bar to be bound to the characters health. It appears always to be completely empty, as if the NPCs health was 0. The health of the NPC is specified in it's blueprint via two float variables: MaxCharHealth and CurrentCharHealth, both of which are currently set to 100. I'm pretty sure the problem lies somewhere here: alt text

What startles me the most is the fact that I used a similar setup for my player character, and that's working just absolutely fine - full healthbar, updates (gets empty when the player takes damage, etc), everything exactly as it should be. I think there has to be some astoundingly dumb failure right in front of me that I managed to miss somehow.^^

Thank you very much in advance and sorry for my English.

Product Version: Not Selected
Tags:
blueprintfail.png (208.7 kB)
more ▼

asked Apr 19 '15 at 08:57 PM in Blueprint Scripting

avatar image

Datarecovery09
15 5 7 11

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

1 answer: sort voted first

The problem here is that you are casting nothing to your TEST_NPC. So it will always fail. Do you have one widget for each NPC? Where is this widget created? If you are spawning your widget into your NPC blueprint, you can add a variable in your widget. Let's call it, for example, "Owner". Expose it on spawn and it will be visible in your "Create Widget" node. So you can set this variable to the NPC that is spawning this widget. Then your "GetPercent" function will take the "Owner" and retrieve his current health, without need of the cast.

more ▼

answered Apr 24 '18 at 10:55 AM

avatar image

DjFrex
66 1 5 8

(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