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"

Switching actors in game deletes part of UI

Heres my issue. Hopefully, I provide enough info. I have one User Interface providing the health bar of both actors. For cannon 1 I have the health I cast to my character get the health and then for the other progress bar I cast to my tank ,when I am possessing my first cannon I show only the cannons health and not the tanks, then when i possess my tank i show only the tanks health not the cannons. It seems when i possess the tank it chooses not to show the cannons then of course the other way around.

I know im getting the health i need for each actor but for some reason, it wont show the other actors health when i possess another.

alt text

Product Version: UE 4.21
Tags:
1.png (97.1 kB)
2.png (76.8 kB)
3.png (87.4 kB)
4.png (87.3 kB)
more ▼

asked Nov 24 '18 at 01:03 AM in Blueprint Scripting

avatar image

Carnage97
5 2 4

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

1 answer: sort voted first

your issue is that your trying to get the player character in each case but the player can only be possesing one character at a time. so when you posses the tank you are no longer possesing the cannon so if you get player character and cast to the cannon (picture 1) it will fail since the tank does not inherit from cannon.

your best bet will be to set a reference for each in the widget when the level starts so you wont need to rely on get player character.

more ▼

answered Nov 24 '18 at 02:26 AM

avatar image

ThompsonN13
10.1k 33 9 23

avatar image Carnage97 Nov 25 '18 at 01:11 AM

Can you please show me an example? ive fiddled around and cant seem to get it correct

avatar image ThompsonN13 Nov 26 '18 at 03:35 PM

post your script for possessing the two characters since that will probably be the easiest place for you to get the needed references. also post where you are creating the widget so we have a reference to that as well.

it may be as simple as having two public variables in your character, then when the widget is created you pass the variables on to set a variable in the widget, then use the variable in the widget as the needed reference. but without knowing your code / setup i cant tell you to do X.

avatar image Carnage97 Dec 04 '18 at 12:28 AM

Hopefully, this helps this is in my level blueprint showing where i hit number 1 or 2 to possess a character then the other two photos are in my cannon 1 user interface where i have the health bars alt text

capture.png (189.5 kB)
issue2.png (136.7 kB)
3.png (167.0 kB)
avatar image Carnage97 Dec 04 '18 at 05:53 PM

I have both of the possessing of characters in one UI. Are you referring to making two totally separate blueprints for UIs one for character 1 and another for character 2?

avatar image ThompsonN13 Dec 05 '18 at 01:23 AM

it looks like your creating your widgets from the level bp which makes things pretty simple. theres a few things that are odd to me however, for example you are creating a new widget each time you posses a character which seems like a waste as your just recreating the same widget without destroying the previous one.

anyways assuming that you want to show the health bars for both characters at the same time heres what you'll need to do. first in each widget create a variable and make its type character (or whatever class your tank/cannon is). next in your binding function "get Percent x" you need to delete the get player character node and replace it with the variable you created. the last thing we need to do is to set the variable to be a reference to the character you want to get the health of. go to where you are creating the widget and drag off the return value pin, then search for the variable your created earlier (set variableX) and use the set version. now take the reference you have to the character in the level and connect it to the pin labeled with your variable.

the pictures below show an example of whats mentioned here. the first picture shows the widget setup, note here in the bottom left the variable type is set to thirdpersoncharacter since thats the class of the character i want the health of. the second picture shows the level bp setup much like your but here im only creating the widget once and i added in the setting of the variable.

if you have other problems with this or this isnt where your issue lied let me know and ill see what i can do.

alt text

alt text

capture.png (130.7 kB)
capture1.png (181.5 kB)
(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