Only a few days before I return home! Good thing there is this miracle called the Internet to facilitate long-distance work from distant countries, eh?
Before I continue with refining the player-enemy interaction system, I had to take a quality-of-life detour regarding the player camera's dynamics with the enemy NPC mesh. By the template default, the camera will treat anything colliding to it as an obstacle. This prevents the camera from clipping/phasing through game assets and revealing their hollow interiors or other items behind them.
What I needed to change was straightforward:
Open up the enemy Blueprint.
Head to the Details tab.
Expand the Collision section.
In Collision Presets, set it to 'Custom - PhysicsBody'.
Set Camera's Collision Response to 'Ignore'.
If capsule component has not been tweaked, repeat previous instructions at the same location.
My next change to the enemy Blueprint was a minor addition in the attack event Event Graph. After a much-needed brain short-circuiting session, I realized it is unappealingly believable for the attack animation to play after the enemy deals damage to the player, comparable to the logic of a punch that hurts before the fist even forms into one. Keeping that idea in my idea notes for now.
Unlike the human body, the virtual body never truly dies when damaged to zero health, meaning players respawn upon death to try again and conquer the trials that felled them at the start. I wrote a script that reopens the level, resetting everything from the starting point shortly after every death. Run my game on it and…
…No respawn. Huh.
See, it turns out an actor blueprint cannot reopen a level as the game mode Blueprints are the only ones who can execute such a command. A simple recreation of the nodes at the third-person game mode Blueprint should get me what I want.
The final touch to my respawn mechanic involved adding a node referencing the Respawn command and sandwich it between the check-if-no-health Branch and Destroy Actor, effectively ensuring the respawn timer starts ticking upon player death. Run it once and…
Voila!
Onto the next step towards greatness, I would like my player to react against the enemy's assault. The animations needed exist in this game's folders and now is the time to put them to artistic use.
To fetch multiple animations for the same model, create an Animation Montage variable that can contain multiple animations in the form of Array elements. After placing each desired item in it, they can be fetched and played with a Play Anim Montage node. Connect a GET Array node to it so it can extract from the Array. As I did below, wanting to diversify the damage reactions of my character, I linked a Random Integer node (coupled with a GET Array LENGTH node) so the maximum randomized value does not exceed the Array size and fetch nothing per run.
Now I have a player character that recoils differently almost every time. Do I beleive it unnecessary? Somewhat. Though I also argue it adds believable immersion to its liveliness, breathing if even a simulacrum of life into it.