Hey all, I wanted to post my initial implementation of this system in case anyone comes across this problem in the future.
First, I took the suggestions here for using arrays of animMontages and @baobao4435’s implementation example using a struct.
I started by creating a Struct for the Actions.
Then I created an Array of Actions in my CombatSystem Blueprint.
This is a combo system I am using that I learnt from a tutorial. It is basic and uses animNotifies to continue and stop a combo.
This event is what play the animations using the Attack Index and Actions Array.
For the reordering of the combo, I am using a simple key press to move an attack to a different place. I still need to implement a more robust system that allows the Player to see all available animations and pick and choose where they go, so the following is a foundation for building that up.
In this example, I am moving the first attack in the combo to the third position and moving all other attacks one index back.
After the function is completed, I set the Actions array to the modified array that is Output from the function.
I probably don’t need the “Array to Reorder” variable since this function is in the same Blueprint but I did it anyway for extensibility. The function also has local variables to make the process easier.
“Temporary Array” is a copy of the original array and it will be the one that is having the reordering done to it.
“Element to Move” is a copy of the array element at the index that will be moved.
“First Element” is the array element at the index that “Element to Move” will be moved to.
Then I added a branch condition to figure out if we are shifting the element to the right or the left. This is because I wanted to create an implementation that moved the other array elements accordingly, not just swap the selected ones.
Again, this is just an initial implementation of the system and will probably change as I develop more iterations.
“Right to Left” is the “True” branch, meaning that the index of the “Element to Move” is greater than the index it is being moved to.
I start off by setting the array element of the “New Index” with the “Element to Move”
Then I start a for loop by incrementing the “New Index” (Index to move to). The For Loop will go from this index to the Index of the “Element to Move.”
The Loop is fairly simple, it gets the element of the current index and sets the “Next Element” to it.
Then I set the array element at the current index to the “First Element” I had stored in the function initialization stage.
After this is done, I set the “First Element” to the “Next Element” and reset “Next Element” to an empty (might be redundant but I did it anyways).
And it loops through that until the Loop completes at which point the return node is called and as you can see in an earlier image, it sets the Actions array in the Blueprint to the modified array from the return.
“Left to Right” is the “False” branch, meaning that the index of the “Element to Move” is less than the index it is being moved to.
I start off by setting the array element of the “New Index” with the “Element to Move”
Then I start a for loop by decrementing the “New Index” (Index to move to). The For Loop will go from this index to the Index of the “Element to Move.”
Now, to my surprise, Unreal doesn’t have a decrementing For Loop natively, so after doing some research and learning about Macros, I created my own implementation of it. I basically just copied the For Loop logic and replaced a greater than check with a less than check. This is it:
The loop itself follows the same logic as the “True” branch.
And there you go, my initial implementation of this system. For now it is a hard-coded change but in the coming days I will attempt to develop a more complex system, perhaps by doing what Absolver did by having a separate menu for Players to go into to do all the edits. Other changes would be to have presets that the Player can switch to during combat to increase variation, similar to Absolver’s implementation. Another would be to add unique attacks if a certain combo stream is used, something suggested by @doctorpepperdan.
Thanks again for your suggestions and help in making this system. I hope my description can help other developers that want to replicate this Custom Combo or Customizable Combo System.