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"

Making game events update the UI

I have my score calculations in the GameMode. And I want to update the UI of all the players with the current score. But I can't figure out how to get a list of all the player controllers, to call a function/event on them, which would be passed to their UI widget with the updated score. The score calculation is behind HasAuthority() so that clients can't cheat, so even if I had all the PlayerControllers would a function call end up being an RPC?

What is the correct way to do an event based update from the GameMode/GameState/Level down to the UI attached to a PlayerController?

I'm trying to avoid polling the GameMode in the UI's Tick() to fetch the score, and instead only updating the text when the score changes. Because lots of things using Tick() will slow your game down, and I've noticed that setting text is rather expensive because it calculates the width of all the characters etc...

Product Version: Not Selected
more ▼

asked Nov 17 '14 at 05:10 AM in C++ Programming

avatar image

570 19 31 49

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

1 answer: sort voted first

My understanding of the intended workflow with UI/UMG is that you bind attributes such as the score/text to functions that are responsible for fetching the updated value, and those functions are called whenever the underlying UI framework decides that they should be polled. Then you simply replicate the scores over the network whenever they are changed, and your bound function retrieves that value for the UI.

Having said that, if you want to do things in a more event-driven way I'd investigate a replicated variable with a ReplicatedUsing function which gets executed when an updated value is replicated over the network - that OnRep function can then 'push' the updated variable into your widget class. There's an example with a helpful comment from an Epic Dev on this forum thread.

more ▼

answered Nov 17 '14 at 07:46 AM

avatar image

1.5k 55 36 73

(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