The most dopamine-brewing aspects of shooter games for me & in general are being able to kill things without risk of real-life punishment.
To make an NPC, I first needed a new character Blueprint. It comes with a Collision Capsule, Arrow and empty Mesh component. This also includes an essential Character Movement component at the bottom of the list.
UE5 provides users with artificial intelligence (AI) tools for intelligent interactions with the active environment. A common application for it in video games is calculating the closest paths between the player character and an NPC.
For the enemy character to know where my player is, it needs the presence of a Nav Mesh Bounds Volume (NMBV). To clarify, a navmesh - short for navigation mesh - is an abstract data structure used in AI applications to aid agents in pathfinding through complicated spaces. Clicking "P" while selecting the NMBV displays every surface area in a level AIs acknowledge.
A yaw is the rotation about the rigid body's y axis (pointing up). If the setting beneath this sentence was enabled for a character, if it is a player, the camera will follow the y axis rotative direction (sideways) of my avatar.
In my own experiments with character movement, here were my primary findings:
Rotation Rate setting toggles how fast the player character will move with its controls, a higher value equaling more speed.
Using Controller Desired Rotation instructs the character camera to face towards the front side of the player character.
Orient Rotation to Movement enables the character camera to rotate around without also rotating the character's direction as well.
Should all of the mentioned settings be enabled, Controller Desired Rotation is overlapped by Controller Rotation Yaw and Orient Rotation to Movement (as they function identically the same) in the camera control categorical hierarchy.
As I have introduced in my 2nd Feb post, the AnimGraph is where I can create the logic for my character's animation sequences. For convenience's sake, I just copied existing movement nodes from my player's event graph and pasted it in the enemy graph in a few seconds. I have yet to reach the intermediate phase of animation graph know-how.
Now let me ask you this: can a senseless entity perceive and act against another in our logic? Maybe to a limited extent. I fixed that by connecting a straightforward event node to a blueprint event note cast (aimed) at the player. For the uncomplicated, I crafted the logical process of "if you, the blueprint carrier, senses the player (via overlap-able, noncolliding sphere sensor), chase them nonstop". See the image below for visual reference.
Travelling back to Blend Space 1D, smoothing animations make them more fluid in execution - less mechanically rusty and more organically smooth.
Animation weight speed setting adjusts how long it takes for merge (progress) animations e.g., a speed of 1 completes the change in 1 second while a speed of 2 completes it in 0.5 seconds.
Smoothing time is the total duration it takes for animations to merge. During testing of my own, a higher smoothing time from 1 second to 0.01 seconds accelerated the transition between animations for my enemy characters.
I smoothed out my animation with smoothing type Spring Damper. The 'spring' part of the system can be thought of as the animation state (like a character moving from a walking to a running state), and the 'damper' part of the system is what smooths out this transition, making it look more natural.
The enemy's chase-and-run animation looks organic thanks to animation smoothing. Without it, these mannequins would have moved their joints like rusted robots.
Now to craft myself a staple trope in video game logic: a health-and-damage system! First blueprint for said system was the bullet. Fetch an Event Hit node, connect it to a Apply Damage node, and the system is complete in less than 10 seconds. Wrap it up with a Destroy Actor node to erase each bullet upon hitting anything so their continued existence no longer strains my laptop.
Upon colliding with a damageable actor, the bullet will inflict a specified amount of damage then be instantly erased by the game system afterwards. Straight and simple!
I made the damage variable but had not created a health variable just yet. Once I generated it, it was time to enforce the physics of ragdoll death on the enemy NPC.
Here is my node progression:
Event AnyDamage sends a signal when the carrier receives damage.
A SET node deducts the current max health by damage taken, setting the current health value to the final result.
A true/false branch blocks all earlier node signals from the final node Set Simulate Physics until health reaches 0 or less, which upon trigger, causes the dead enemy to flop on the ground.
Now look at it funnily drop dead from afar! Good thing the player has no health to be damaged… for now.