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"

C++ Ammo works, but doesnt show on screen?

I created C++ ammo counter, which basically lets the player shoot only 30 times(like a magazine), I was trying to add the player ammo with the UI Widgets, however, I get 0 when I press play. P.S The ammo stop system works, it does let the player only shoot 30 bullets, and it doesn't matter if he does it in full auto or by pressing a lot of times. The problem I have that the UI Widget shows 0 all the time doesn't update how much the player has ammo or used. Ammo system is in Weapon class, so in UI widget I cant cast it to BP_Player(Character blueprint)

Screenshots: alt text alt text alt text alt text alt text

Product Version: UE 4.19
Tags:
0.png (567.0 kB)
bpchar.png (93.5 kB)
c-mag.png (4.8 kB)
ui-widget.png (108.2 kB)
more ▼

asked May 04 '18 at 07:49 PM in C++ Programming

avatar image

Gromis_
1 1

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

1 answer: sort voted first

It doesn't look like you're setting the owning player when you create the ammo widget.

more ▼

answered May 04 '18 at 07:58 PM

avatar image

Velrin
375 2 8 13

avatar image Gromis_ May 04 '18 at 08:03 PM

Can you be more specific? as I'm really new to blueprints. :D so Get Owning Player Pawn doesn't set the owning player?

avatar image xSheim May 04 '18 at 08:20 PM

in your third screenshot there's a blank node: OwningPlayer. You should set it to your pawn to get GetOwningPlayerPawn() working

avatar image Gromis_ May 04 '18 at 08:34 PM

didn't work :/

avatar image xSheim May 04 '18 at 08:44 PM

could you show me the current setup?

avatar image Gromis_ May 04 '18 at 08:53 PM

I tried this, however, it shows an error that self isn't a widget and from that point I cant "Get" anything else. So I think the problem is c++ code.

alt text

self.png (110.3 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