cast to component object wildcard unreal engine 5,2

Hello i ghave a question

i am using the new Fps Tamplate in Ue 5.2
what FYI is terrible to work with

but i run in to a problem when i want to add a weapon count to the UI with casting to the default BP_Weapon_Component because i cant seem to find out what to add in the object pin

thanks oyu in advance

Where is the weapon component you’re looking for? Which actor owns it? Casting is not a way of finding something - this is your job. What if there are 3 weapon components - which one do you mean?


Also, is it necessary to make a hard reference? Would it be easier to: update ammoupdate widget instead?

well the default Ue 5.2 FPS tamplate only has one

and this is were i coded the ammo count and reloading

so i need ot cart to that exact one on the screenshot to get the ammo count

only get stuck on the object ref

also tryed a ref to self didnt work

no idea why its the first time i have this problem with casting normaly i would do it all in the Player but 5.2 is a mess with how the set it up

to were even the basic gun systems are spread over 3 actors

I know the system. It’s versatile and a great starting point. Why not create the widget in the weapon component. It’s the weapon component that has the ammo and keeps track of it, right?

All of this is compartmentalised in the comp, each weapon has its own widget. Makes things transparent. It’s event driven, no casting, it happens only once when the ammo count changes rather than 120 times per second in case your next step was to bind a function to a text block…


Avoid having widgets pull data out of somewhere, it’s tedious work. Widgets’ job is to display what you send them and, most importantly, you should decide when the update happens.

Consider it.

okey yea that doesnt say mutch to me im a level designer not a programmer to started leaning it with a simple shooter project so i followed this
video

and this is how i have my ammo / reloading setup

Ammo:

Reloading:

Shoot function

The entire working setup is in my screenshot. Create a widget in the weapon component and call a custom event inside, something like:

You already have all the necessary ammo counting functionality in the component, which is great.


Since you’re following a 3d widget tut of some kind, how do you attach it to the spawned weapon component? Do you even do that? There is major differences of how one would set up comms between a regular widget vs a widget components.

Perhaps do tell more about how the widget component is supposed to work.

Sure

so all my Widgets are 3d space like this health and armor

This is attacted in the Player it self:

same as the ammo counter
image

and those are all contected in one widget:

Even better - there’s no hard refs here whatsoever:

Have the weapon dispatch ammo count to the player’s widget component. This is using the same Custom Event as before. This way any weapon can send anything to the same widget the player owns.

The dispatcher in case it was not clear:

okey so how would i do this when im using max and current ammo

also i tryes this but is does not update the ammocount
Mabey i misted something

so its now fully working

Thank you so mutch

image

And this is how i feel now after hours of pain :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.