I am designing a game right now where the guns damage, reload speed, and other traits are all held in a Blueprint class that is the child of a parent class. The parent class holds all the variables that the children get. I am having problems with editing them though. I want it so you can go to base, open a widget menu, and purchase upgrades for said weapons after you unlock them. The purchasing works but even when doing a cast to blueprint I can not seem to change their values. Any ideas?
for context, I need to edit the children individually, one upgrade shouldnât be applying to all the weapons.
Show the blueprint where you set the values and the one where you read them (preferably with print string)
Are you sure you are reading the values of the same object youâve set? What about right after setting?
- u donât need the cast because the variable is already âpistol a full autoâ
- use pistol a full auto broken the use of a parent class so better change the variable to âweapon masterâ
- I donât see anywhere that you pass the pointer that refers to your widget variable
Iâm having difficulty understanding would you have a screenshot of this setup?
Oh! So youâre saying the cast to is the problem?
I tried this setup but I just get the accessed none error.
What I am noticing is that the variables can not be set from outside the blueprint class, is there a way around that?
I believe the issue is likely how youâre referencing your BP actor. Most probably, you arenât referencing the instance of the actor you want at all. Below is a very basic set up, which works by crudely grabbing hard references. I highly recommend using interfaces where possible, but just so you can see whatâs needed:
As mentioned, âGet Actor Of Classâ is crude, so you may wish to define your actors with collision overlaps, and/or tags, and/or unique interfaces. Store these actor references in your player character or components attached to something else persistent in your level.
Consider checking out inventory or item tutorials online for more specifics.
Oh so like add a collision sphere that makes the weapon update by having variables stored inside the player from the upgrade menu?
I wish this would work though but it is not an actor but a class based of a parent class.
The system I use is actually based on inheritance (parent class), I just threw together a simple mock-up. However, the key takeaway is that you canât get a reference to a specific actor in your level until your level (and subsequent actor) has been rendered.
You are referencing the generic BP actor (the file), you need to reference the very specific instance of it in your level. In other words, if you have three of the same swords in your inventory, which specific one should be equipped, or increase in attack value.
My item system is a Frankenstein of many different concepts, so I canât give you an exact link to a tutorial for a better explanation, but the item defining bits come from here (how to get the actor reference into your widget):
Pick Up Item Using IK In Unreal Engine
Essentially, attach a collision volume to your player character, which speaks back-and-forth with the overlapped items (actors) to create references for use later, instead of âGet Actor Of Classâ nodes. Once your player has references to your items, you can allow the items to store their own variables since the player is persistent, but others might recommend data tables for item attributes and stats. Again, a tutorial would be a good place to look for a more in-depth, modular system.
Another type, which is a bit more widget-based is here:
Slot Inventory Tutorial Part 1 - Unreal Engine 5.4+
I imagine the rest of your set up is fine, so you may only need to consider how references are handled, and how definitions are passed between the widgets, player, and BP actors (items).








