This may be more of a question about enumerators in general - but I would like to know how I can use a custom enumerator variable in the character blueprint to point to existing weapons blueprint classes to bring the selected weapon to the player’s hands (Viewport), along with its functionality?
My custom Enumerator in my “BP_Firstperson” class has the values: “Tommy Gun”, “Shotgun”, and “Pistol”.
My weapon blueprints are: “BP_Weapon_TommyGun”, “BP_Weapon_Shotgun”, and “BP_Weapon_Pistol”.
Each weapon class has its own unique functionality, so, the question, to reiterate is:
How can I set it up so the enumerator actually “Knows” what it’s referencing? It would also be nice to use an enum to handle the ammunition classes as well.
Once I understand this, I can get the weapons in the viewport, and hook up their corresponding state machines in the animBP.
You could use a DataTable to store the information. In this case I would probably make the row name the same as your Enumerator: “Tommy Gun”, “Shotgun” and then have a variable with the weapon class. Then if you want to spawn the weapon, you can use “GetDataTableRow” and insert the Enumeration-to-string as RowName to get the weapon class.
You could store the data in a map. Make a variable with your Enum type, then change it to a map and select actor-class as 2nd variable type. Then you just can use “find” on the map to get the weapon class.
I would prefer the first option because it’s more flexible and perhaps a char has a rocket launcher as a shotgun or something like that, when setting up different data tables for different characters. You also could add another variable to the table to make the weapon available or not by just clicking a bool and so on…