[Attacking Command]
With the UI in place and the combat component carrying all the information a "Unit" character needs it's time to program some functionality into my project. To Start off I created a custom event which I will be calling again later, once this event is called I need the chosen unit character to move towards the selected enemy and back to its original battle position, then I added a variable containing an animation montage and told it to play the animation upon attacking. The animation that plays can be changed on a per character basis as each character will have a different skeleton which wouldn't immediately work with that last chosen animation. To apply damage to the chosen actor I created two functions that take values from the combat component stat structure and from the parent unit class stat modifiers then combine them together to create a single damage value and the second of these functions will take the single value result of the first function then subtract how much damage will be resisted by the type of enemy unit which is receiving the attack.
[Ranged Attack]
The Ranged version of the basic attack command starts off similar to the melee attack command where the party unit moves to a new position, plays an animation, then returns to their original positions however, if a unit character is using magic or a bow or a gun they need to fire a projectile of some sorts to make their attack animation appropriate to their weapon.
To enable the projectile from this animated attack I created a "Notifier" blueprint which will communicate to all other actors letting them know what has occurred, with the notifier on hand it needs to be placed within the animation montage and from there I can return to the Ranged Attack Command event within the Combat Component and drag off the "On Notify" pin of the attack animation and spawning the projectile to be used as an actor and have it seek out the enemy unit.
[Animations]
All of the "Command" options that can be accessed by the player need a animation that plays on screen to go with them so the player is aware that their selection went through. Since within Unreal Engine animations are tied to a characters specific skeletal mesh you would need to re-target the same animation to the new character skeleton or you could create a new character model specific animation, however, in either case the developer working on this project needs to re-assign the animations for each newly created character (or any character where the skeletal mesh has been swapped) and I have made this process easier then usual as the animations that will be used during battle actions are tied to empty variables saved on the top parent class ("Unit Base" & "Combat Component") so all a dev needs to do when adding a new character is head straight to the bottom level child blueprint, which would also be where they selected the new skeletal mesh, then find the empty variables labelled "Animations" and select the appropriate animation sequences.
Comments
Post a Comment