Hi, this is my first forum post and I could REALLY use some help with figuring out how to get this weapon system I am using into a data table and being able to reuse that rather then having to change everything separately based on the weapons Blueprint.
I did use a tutorial to help get an understanding for what I need, and this to is a continuation of that practice. I figured out the center of the screen line trace by myself and connected the system to a basic combo system I have for when the player is Unarmed.
If this data table is right then how would I then go about getting the information from each entry per weapon? I had an idea to put it into its own Actor Component and use it just for storing data on interaction and depending on what’s being looked at displaying the weapon name on screen. Then using the Actor component I was thinking of making functions for the separate actions from the tutorial like getting a weapon of type : 1:22:10 , Set Weapon of Type : 1:27:00 , Get Current Weapon : 1:30:50 ,and Set Weapon Visibility 1:36:40.
I would greatly appreciate some input on this and some clarification on how I should move next, even if the recommendation is to start from scratch I just need some direction on where to take this for an expansive easy to add to system that allows for both ranged weapons and melee weapons. I also have light C++ training and have dabbled with unreal since 2017, I am familiar with many systems it has I am just lacking on advanced scripting and blueprint methods like Data tables.
First of all, make ALL references soft (Pickup Class and Attack Animation). Otherwise you risk getting bigger memory problems.
Just use the Get Data Table Row function.
In the parent class, you need to create a variable of type “Name” to store the Row Name of your Data Table, on the basis of which the weapon was created.
You also need to make a function in the weapon that will “load” all the parameters from the Data Table.
You will also need side functions, for example for damage - you also get it from the Data Table when needed.
Parameters such as the size of the clip - will also be in the Data Table, but the actual number of bullets left in it - should be stored in the blueprint.
Sorry for the late reply, thank you for responding. I have not learned much yet on memory practices since I have only done smaller scaled projects thus far so your tip is helpful and a reminder that I need to learn more.
My new question is what about my weapon damage trace is that something that I should store inside of the parent weapon bp, individual weapon BP, or the Player BP?
I understand the bullet functions for adding and removing something like a float variable in my data table to use as my bullet count but I struggle to grasp "Loading" parameters based off of a data table. Would it be similar to Storing a reference to "Data Table Row" then setting the default value to the weapon data table and adding a function to change the row name when the function is triggered?
I would absolutely love to hear your feedback anything you can teach me on practices would mean millions to me honest.
Do you mean the logic that will trigger the Line Trace of the shot?
In your Parent class you create an abstract (empty) function “Shot”. Then in the child classes you override what this means for each weapon type.
A shot from a pistol and a shot from a rocket launcher are not the same thing, but any weapon can be fired using the Parent function “Shot”.
The “Shot” function itself will be called through the general control interface from the character, but that’s another topic.
When working with Data Tables, you just need to remember that the data in them cannot be changed during the game.
Therefore, you cannot store there, for example, the number of remaining cartridges, or the wear of the weapon.
I see, so correct me where my understanding feigns.
I make the struct, the struck has : a name, a skeletal mesh comp, variables for damage, range, etc.
I then put that into a data table and store the model I want per entry, along side the name, etc.
Then in my Parent weapon BP I would create functions that call on Get Data Table Row to get the separate information based on the Row ID that the weapon is in. Store the information that is output to a local variable inside of the parent class that can be called upon the children created?
Do you have any kind of reliable resource I can check out that might be able to give deeper understanding on How to make a function for gathering and storing variables from a data table? Honestly if it is ever an option for you and if you have the time I would kill to be able to talk to you one on one about data tables I really desperately want to learn this but I lack the knowledge and understanding of what practices I should follow making online education videos hard to pick. (I.e. I dont know how to tell if the information I am getting is good or bad)
There is no need to save information from the data table to variables, this is a waste of memory.
It is enough to just store the Row Name that contains the required information and then get information from the table using Row Name.
Data Tables are a pretty simple tool. All they do is store a relationship between a name and data based on a structure. All you need (mostly) is to call Get Data Table Row - and get the data. You can NOT change a Data Table during the game, it is a static storage for some information, that’s all.
THE MOST IMPORTANT and perhaps the only nuance is that ALL REFERENCES in the table must be SOFT.
If the reference is hard - it means that the engine will load this object into memory automatically, if it is soft - then you decide when to do it (or not to do it at all).
Size Map will help you understand how much your object is actually worth.
If your table contains hundreds or thousands of references for models, textures, sounds, etc. - all this can weigh several gigabytes. And this will mean that as soon as you use the data table somewhere - it will automatically load ALL these objects, and your memory may simply run out and the game will crash.
You clearly don’t want to load half of the project into memory in a situation where you only need to get a description for a one pistol, right?