I’m basically trying to make an rpg. I made a parent spell that calls onto a blueprint structure. Then in the children I just fill out the damage and stuff for it. For the sake of simplicity I want to be able to just tell the overlap to check for the spells damage without having to literally list out every spell in the blueprint. How do I get that to happen? I thought if I cast to the parent it would check the children, but apparently I misunderstood the point of parent-children blueprints. I’ve thought of flopping it where the damage is done in the spell and it just checks to thing it hit, but I don’t know how to grab the health from the thing it overlaps without having to once again list out a million things.
I’ve only followed tutorials until recently and I’ve been trying to do things on my own.
This is what I have tried so far and apparently doesn’t work (InstantSpell is the Parent and this is the blueprint for the rock that you can break for materials):
I might be wrong but I think you are asking for a way to get the damage for a specific Spell Actor.
From what you shared I get you have an InstantSpell class with a struct containing all its defining stats. Doing what you did will get the stats of the colliding specific Spell (say FireSpell).
If FireSpell inherits the struct containing the stats (say SpellStats) from InstantSpell, and assuming you set the stats for FireSpell during init of FireSpell object, what you did in your screenshot will always return the stats of the instance of FireSpell currently colliding with your Rock Actor.
A good way to store all the specific stats per spell would be a DataTable, where you could just list all the stats with for specific spells, indexing them with a SpellID (wich needs to be a variable of the InstantSpell class). Doing this you will simply have to get the data relative to your currently colliding Spell ID from the DataTable whenever you need so (and you can encapsulate this logic in a function in InstantSpell, and just use that to get wathever stat you may need for your spell)
Hope this helps
You need 2 parent blueprints, one for the spells with a struct that stores all the stats you would change between different types of spells and one for the characters this spell is going to do damage to and reduce their respective health. Once you have that setup, you make a child blueprint for each new spell and a child for each new character. In the parent BP for the spell (or character which ever you prefer) you would set up an overlap event and cast to the other parent BP. So from the spell it would be
On overlap, cast to parent BP for characters, off the character object pin get health, subtract necessary damage (set in the child BP of the spell) and finally “set” character health. This way you only do one cast from one parent to another on overlap and the rest is handled by the struct and stats set in the children. If you need more help later I can post the method for doing this.
I’m asking about something way more complex. I do appreciate the answer, but I have already done that and I’m asking about simplifying code when comparing 50 spells to say 50 different destructible items.
Haha, no problem. Didn’t know where you were in the process. Just throwing ideas out. I never used a data table but I’d be interested to know how that works out.
I looked into what data tables are and I don’t see the use. Why not just assign a damage variable to the spell? I want to make a ton of spells and then have the things they hit check the spell and its damage without literally listing out every single spell in the overlap function.
So I did find a solution on my own using data tables. Basically I just made a data table that contained damage, model, sound, etc and when the projectile spawns, it gets assigned a number. then it just takes all those things and turns it into the spell it should be and i just have to do a single spell to cover an spell i could want or make. now to learn how to change projectile speed after it has spawned.
I would imagine that wouldn’t be hard. Get a reference to the projectile, get the projectile movement component, get “current speed” and set it to whatever you want.
Glad to hear you found a solution and discovered the benefits of data tables.
As Nebula Games just said, now changing projectile specific variables at runtime shouldn’t be much of a problem.