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"

How to display score from multiple character blueprints

I'm making a single-player game where you can transform, each character has they're own character blueprint, and you score by collecting coins. My HUD only shows 0 and doesn't update at all.

What elements should I call where?

How should I go about this? Thanks!

Product Version: UE 4.14
Tags:
more ▼

asked Feb 07 '17 at 08:24 AM in Blueprint Scripting

avatar image

juztinmikael
28 4 8 10

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

1 answer: sort voted first

Hi,

where are you storing your score. If you aren't doing that already, try soring it in the PlayerState. It presists even if you destroy and spawn pawns.

PlayerState

A PlayerState is created for every player on a server (or in a standalone game). PlayerStates are replicated to all clients, and contain network game relevant information about the player, such as playername, score, etc.

The PlayerState can be accessed via the PlayerControllers PlayerState variable.

more ▼

answered Feb 07 '17 at 08:40 AM

avatar image

JanW
136 3 2 9

avatar image juztinmikael Feb 14 '17 at 02:21 AM

My character blueprint parent-child setup is like this.

-Main Character

--Type 1

--Type 2

I tried this tutorial but it's only for a single character blueprint.

video link

Any ideas on how I should go about this? ?

avatar image JanW Feb 14 '17 at 06:21 AM

Have you tried as I said in my Answer above? With the playerstate you get a place independent from you characters where you can store your information.

avatar image juztinmikael Feb 14 '17 at 07:46 AM

Hi there, this is what I came up with. Still haven't figured it out :(

Game Mode alt text

Player State alt text

Widget BluePrint alt text

Score Not Appearing alt text

hero_game.jpg (53.3 kB)
score_widget.jpg (72.8 kB)
noscore.jpg (25.1 kB)
avatar image JanW Feb 14 '17 at 08:03 AM

Try adding a "PrintString" to the "Cast Failed" in the Playerstate to see if something goes wrong there.

avatar image juztinmikael Feb 14 '17 at 08:11 AM

I added PrintString to both PlayerState and my WidgetBlueprint and nothing appears on my play screen

avatar image JanW Feb 14 '17 at 08:24 AM

Could you add somthing to the widget that is always drawn even if the values of the score are not available. A progressbar mayme. To make sure the widget is rendered.

avatar image juztinmikael Feb 15 '17 at 06:42 AM

The progress bar works but not the score. The score is supposed to be beside the character's head.

The PrintString is also displayed from the GameModeBluePrint and LevelBluePrint.

I think I'm close ? ?

alt text

progressbar.jpg (43.0 kB)
avatar image JanW Feb 15 '17 at 07:04 AM

Did you tell the Gamemode to use your Playerstate? alt text

avatar image juztinmikael Feb 15 '17 at 05:36 PM

Yes I did, but still it doesn't show up

avatar image JanW Feb 16 '17 at 07:19 AM

Try adding a Breakpoint at the "ToText" node in your widget (Select it and press F9). To see if this node is ever reached. Also try to remove the "Cast to Hero_Game" in your player state. You dont need it there.

avatar image juztinmikael Feb 16 '17 at 08:28 AM

I checked it and the node is reached, and the score is now displayed! Thanks! !

alt text This is what I came up with to get the widget working.

Score Widget Blueprint alt text

PlayerState Blueprint (AddScore Function comes from here) alt text

Character Blueprint alt text

Game Mode Blueprint alt text

Powerup Blueprint alt text

I still get the score even when the character transforms into a different character (blueprint) which is what I exactly need.

I'm not totally 100% sure why it works now but I got it somehow using your tips and concepts. Thanks a lot

(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