DataTable to Projectile - How To?

Hello there ! I’m currently tearing my hair out on an issue.

I’m working on a top down shooter, like a bullet-hell / rogue like. Right now, I want to work on the scalability of the project and start to store weapons data on a Data Table. But I struggle to figure out how to use my data (minDamage, maxDamage, range, …) that is store in my Data Table, with my attack function.

Till now, I’ve done my tests through BP Child of a Weapon Base BP parent, that store basics variables like damage and so on. Used the class of the actor to spawn the right projectile and do the stuff (init, destroy, range, attack speed, on hit, …).

BUT, Now that I want to use Data Table to store data of each weapon, I can’t figure how to use these data, for the simple reason that I need an actor class to spawn my projectile, and I don’t know how to link my data from DT to the right actor, then store it as my current weapon to shot the right projectile.

So far, I’ve :

  • A Data Table that store needed data (minDmg, maxDmg, range, attackSpeed, mesh, …)
  • A WBP that display my current inventory (via an array of name and a Get DT Row)
  • A BP Player Character where the fire event is called and the projectile is spawned
  • A base weapon actor that handle projectile logic

How can I achieve my goal ?

Hi there
If your WBP has a parent class, on begin play, get data table row, assuming the row name is the name of the weapon. From the output struct, break struct and connect the pins with the correspondent variables min damage, max damage and “set” all current values. All child BPs will inherit this logic. Then, make sure to add “begin play”+ “add call to parent function” in all weapon childs.
From your player, get current wepon, get projectile class and add spawn actor from class. Make sure the correspondent variables inside your base projectile actor are set to editable and exposed to spawn. Get a variable from your current weapon and connect to the correspondent input pin generated in the spawn actor from class node.

Hope that makes sense.

Thanks, a LOT ! Dunno why, I was a bit dumb, never think about expose on spawn the needed variables to set these in the spawn actor (while I do that very often through a construct widget).

You’ve blessed my day, everything works as intended rn !

1 Like

I am glad I could help you. Keep up the good work.

1 Like