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"

Increase Score when a goal is scored

Hi guys, I'm stuck again with trying to increase the score every time a goal is scored. Right now when the ball overlaps the object, it runs one of two custom events from an external function as seen in this image: alt text

The image below is where I'm assuming I have to make a reference to the object within either of the two custom events: alt text

This function is working and fires correctly as the print string shows, however I also need it to increase the score for either Red Team or Blue Team. I have set up the function that binds the text but cannot seem to get the text to update when the goal is scored: alt text

Thanks for the help in advance, sorry if I have not provided enough information, feel free to ask for more if it's needed

Product Version: Not Selected
Tags:
goal-trigger.png (370.5 kB)
ball.png (209.0 kB)
ui.png (201.8 kB)
more ▼

asked Mar 22 '19 at 07:49 PM in Using UE4

avatar image

Chip_14
5 1 2

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Hi Chip_14.

You are correct, to call the function in your widget you need to get a reference to it. The best way to do this is to store a reference to the widget when it is created and added to the viewport (this is usually done in the PlayerController or HUD). Once you have the reference you can call your text update function.

I have a couple of comments about your project setup which you might like to take note of.

I see you are using your Ball blueprint to keep track of current scores. This might be problematic if your ball is destroyed or if you spawn a new ball, since that is where all your information is stored. I would recommend moving "BlueGoalCount" and "RedGoalCount" variables to your GameMode along with the events you use to register if a goal has been scored.

It is good practice to not store game information in world objects, keep this information in your game object classes like PlayerController, GameModes, GameInstances etc.

Once your GameMode has the score information, you can then loop through your player controllers and ask them update their UI.

One final comment, you don't need to use an bound function to update your UI text, you can access the text node directly (providing it is marked as variable) or bind the text widget to a text variable.

more ▼

answered Mar 22 '19 at 09:07 PM

avatar image

Alekann01
441 4 5 6

(comments are locked)
10|2000 characters needed characters left

You need to somehow get a reference to the Car_UI widget. Not sure where this widget is located (3D widget component, viewport etc) but that will determine how you get the reference. Post some more screen shots of how you create this widget and where it is located and I will be able to give you a better answer of how to reference it. You can also check out video #25 in this series about creating references that might give you some tips.

https://www.youtube.com/playlist?list=PLyu-W38DvZhqByAoeva1jewB5s78zQHIy

This video also shows how to reference a 3D widget component (albeit from another widget) but you can use the same method to reference a 3D widget in any BP if your widgets are 3D components of other actors.

https://youtu.be/BdARbvNrvQE

more ▼

answered Mar 22 '19 at 08:07 PM

avatar image

Nebula Games Inc
4.6k 27 9 14

avatar image Nebula Games Inc Mar 22 '19 at 08:08 PM

Also, I see I helped you with a prior referencing issue with this series. Anything in particular different about this one you couldn't figure out from the videos? The last video is a different one FYI if maybe that was the issue. If not let me know what the trouble is with the references here.

avatar image Chip_14 Mar 23 '19 at 02:22 AM

Thanks for the help! I decided to re-watch the video and it helped a lot, I used what you put there along with the help of the other answer and made it work :)

(comments are locked)
10|2000 characters needed characters left
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