Display multiple ammo on weapon wheel

Hi,

I have a weapon wheel that displays the icon of each gun but I’m trying to add the ammo for each gun aswell

Here I cast to the character and BP_GunBase which contains the AmmoCurrent and AmmoReserve among other variables

Currently I bind the widget like so but this only works for one weaopn and only when I have that weapon equipped so not good for this.
image

anyone got any suggestions?

When you create the widgets (in the player?), set the references there. You can use Exposed Vars, no widget script needed.

Alternatively, give each widget an ID (enum or int) and ask each instance to access a specific weapon instance, rather than Currently Equipped.

So I’d need to create more variables in the player? The only reason I can get the ammo currently for one is that the child holds all the ammo and it would be a pain if I need to creat more ammo types on the player character

As for the widget they are all the same instance so that the styling remains the same

I do not understand the setup.

  • all guns use the same ammo
  • you have many different guns
  • you keep the ammo in the gun

How do the other guns know how much ammo is left?

technically yes, currently they all use the same ammo per se.

The gun parent holds these and more
image

On every child I call this Parent function
image

On the parent of Start Shooting it then subtracts one from the AmmoCurrent on every succesfull shot fired on the child gun
image

I guess this is very rudementary as my end goal is to store and save the ammo and also allow for ammo upgrades

The system does work like this, as you can see the guns do save how much ammo they have per gun but I guess this is too simple for what I want

So each gun instance has its own ammo pool, right? Makes sense.

  • so we’ve got this:

image

  • main hud has 3 weapon widgets:

image

Each widget has a base weapon class var so you can property / function bind the ammo count.

  • not sure how your guns get into the game, so I am improvising. Giving the player three guns and assigning values to the widgets’ ref variables:

Does it make sense? Essentially, each widget gets a reference to one weapon. The widget does not care what current is, it polls data off the ref we fed it.

I understand most of what’s going on. My current setup is very bad I know, yours is much more efficient, see if you can make any sense of what Ive done so far

This is the gun spawning logic

The weapon wheel widget is created on the W_PlayerHUD. I’n not sure if all those nodes plugged in like that is neccessary.

And I toggle it on the Player controller like so

I’ll try to implement what you’ve provided but how do I plug in the target here?

Sorry, I know there is alot here

Sorry to bring this up again but in terms of storing and saving things like AmmoCurrent, ClipSize, Recoil, Stability and damage per weapon would this be better if I migrate it to the player?

The only way I can think of doing it is to have them all there but this would increase the list by 5 times if I had AmmoCurrent for Pistol, Shotgun, Rifle, Sniper, RPG, ClipSize for Pistol, Shotgun, Rifle, Sniper,RPG etc all on the player. As you can see here in my Gun_Parent the list is long.

I’ve done a few tests with the AmmoType and it works as expected. Here you can see that I decrement the ammo stored in the player, this also allows me to update the weapon widget easier, but maybe less efficient??

I havn’t seen any tutorials about this either so really not sure, any advice or examples/tutorials would be great if possible.

Nah, it goes into weapon actor. You give each widget access to the weapon (I personally wouldn’t and drive it with events, but get it to work as is for now).

how do I plug in the target here?

The widget has a weapon variable, we set its value to the weapon we need.

  • if this is your widget:

  • the player can grab a weapon actor and tell the widget to reference it as well:

We tell a widget which weapon actor to communicate with.


Normally, you’d have the weapon create a widget and add it to the player’s HUD, that’d would avoid any mess. The widget belongs to the weapon after all, the hud just shows it. But it depends on how it all works. If you only have 3 weapons in the game and the player does not pick up anything new, you might as well create it all upfront, as you did.

1 Like

thankyou for your detailed response, I’ll continue with what I have then. Currently when I select a weapon it spawns them all :sweat_smile:, I now think it’s due to each weapon selection being derived from one widget so I’ll look for a way to fix that

image
image