I’m work on a game that will allow the player to make there own combos in a menu. So say they have a three hit combo and actions, jab, cross, uppercut. They can put those into any one of the three slots and then when the player presses the attack button they preform the combo they made. Normally in C++ I would make a Attack class with the variables and functions needed, then override those in in children and then set the different children to the array for the combo.
I’m trying to move that up into the Unreal editor so it is easier for the none programming designers to tweak values. I’m curious what might be the best data type and way to do that through blueprints.
Thanks for any help and advice.
you can still use a base class and children in blueprint, or maybe just a DataAsset?
I figure, hope, that inheritance is still a viable solution. I’m more curious as to what the datatype should be with blueprints. Should it just be a UObject? The other thing I’m trying to figure out is how to create an instance of it to reference its default values for variables and calling functions. I tried using Construct Object of Class and passing the reference into a array, but the array is empty.
I’m sure I’m missing something small, I feel like this has to be something that is more commonly done.
Maybe make a struct/ data table, give the class an instance editable data table row and a widget to assign active abilities/animations/data
you can get the default values straight from the class, construct is only needed if you want it to do logic.
but if you don’t want it to do logic then a Data Asset is better or a DataTable but they don’t support inheritance
So that is what I was trying, but the reference is always none. I tried both object and class reference and constructing it and casting it.
I recently made something similar: A weapon with an array of attacks.
I ended up using an actual actor to make the use of projectile and melee attacks equivalent. (except the melee hit is stopped if the attacker is interrupted)
I was spawning them on each attack which is not ideal but I’m sure I could have reused one actor for each character attacking.
can we see the code?
Sure.
I’m not sure what are you interested in but…
Here is my weapon setup:
Here is the base attack actor: It only provokes hit reaction and it has no check for the target - always hits.
This is how the Character is attacking:
It’s pretty much it. If I was making it anew I would probably relay on AttackActor replication instead of the multicast but otherwise it works.
Oh and there is no collisions or checks for the enemy - it just hits whoever you are targeting from miles away. I didn’t need that for what I was doing.
Sorry for the delay, I was busy over the weekend and then wanted to make sure I actually got things working before I updated things. I will post my solution below, It does require some minor C++ work, so I don’t know if there is an answer that can be pure blueprints.
Step 1: Make your base class in C++
Note: Make sure the UCLASS has tags Blueprintable and BlueprintType if you are deriving from UObject or another class that does not have those (Actor and all it children already do).
Make sure the UPROPERTY of the variables has EditDefaultsOnly tags
Step 2: Make children blueprints of your base class and set there default values
Step 3: Add the variable that is the base type and is a class reference, then set that variable
Note: You should make sure that it is set to at least the base class even if it is being changed elsewhere.
Set 4: Use Get Class Defaults to reference the defaults wherever you need it
Hope this helps others. If you have any questions let me know. As I mentioned at the top, I didn’t find a solution where the base class could be a blueprint. That is fine for me, but if anyone knows what is needed to do that and wants to add it for others that would be great.