I’d like to share a solution that notifies about a possible attack with a ranged weapon. I use this approach in my game.
In its core, this solution (I’ll call it “the Enemy Attack Prediction System”) extrapolates movement of pawns (e.g. Hero and Enemy), and it notifies the victim if there is a range weapon attack threat.
In my game it is the player who is notified about the possible attack. To visualize the attack threat I used a moving arrow that indicates the direction of the possible attack.
This is in the context of my Single-player third-person shooter game which is based on a Lyra Starter Game in Unreal Engine 5.4.
This is how it looks in action (note the reddish arrows from 0:17 to 0:19):

Handled Challenges
- Regarding user experience: Alerting the player should be discreet, i.e. it should not alert in obvious threatening situations when both enemy and victim (or a player) see each other or when there is attack which is already taking place, or very soon after the eye or fire contact. This is handled with the logic which uses Gameplay Message Subsystem and manipulation with time thresholds.
Particularities:
- Since victim can be shot in different parts of body (e.g. head, torso, feet), the Enemy Attack Prediction System should consider it too. For example, if a cover hides only a part of a victim, whereas any other part stays exposed, attack threat alert should still take place. This is handled with tracing against selected sockets on a victim’s body.
My Solution
- Core functionality (such as ray casting, movement extrapolating, static obstacles handling, threats registering etc), is implemented in C++. See AMBCG_EnemyAttackPredictManager in my solution.
- Communication with other systems of the game (pawns, threat alert visualization), alerting logic is implemented in the blueprint inherited from the above C++ class. See BP_EnemyAttackPredictionManager_MBCG in my solution.
- Threat alert visualization is implemented in a blueprint.
Please note that although the C++ class was designed as enemy quantity agnostic class in mind, it was implemented and tested only to handle just one enemy (as for my game requirements at the moment).
C++ code
Here is the repository with AMBCG_EnemyAttackPredictManager class implemented as AActor.
Enemy Attack Prediction Manager blueprint
It’s BP_EnemyAttackPredictionManager_MBCG – AMBCG_EnemyAttackPredictManager‘s child blueprint.
Here are the screenshots with the key BP functionality:


Threat alert visualization
In BP_EnemyAttackPredictionManager_MBCG‘s there is “AlertPlayerAboutAttackThreat” function where the attack threat visualization is initiated.
The attack threat visualization could be done in many ways. For now, in AlertPlayerAboutAttackThreat I just spawn a simple blueprint actor which contains Arrow and simple logic that moves the arrow to the Victim pawn from the predicted attack direction. After a short time this actor is destroyed.