He cannot move or harm players while being looked at and he maintains eye contact to ensure they are doing so.
Key design focus was to introduce a dynamic enemy to create unpredictable situations.
He is almost harmless when alone but, when combined with other entities it creates very unique scenarios.
Design
Sight Detection System: Upon entering 40 meter radius of him players get added a temporary actor component.
This actor component has a PawnSensing component.
On, OnSeePawn event I send an interface message to the enemy.
This message triggers the event that stops him from moving or attacking people.
This event at the and has a retriggerable delay that is 20ms longer than the sensing interval of the PawnSensing component, if the delay succesfully triggered then he can move again.
The actor component is removed upon death or leaving the enemies radius. To not have a frequently updated PawnSensing component at all times for no reason.
The actor component is removed upon death or leaving the enemies radius. To not have a frequently updated PawnSensing component at all times for no reason.
Eye Contact System
When a player starts looking at him, the player gets added to an array. He always follows the nearest player that is looking at him with the "Find Nearest Actor" node.
• Head movement: The nearest actor is promoted to a variable which is accessed by the multithreaded animation blueprint. Neck bone is moved smoothly using linear interpolation with the "Look At" node, procedurally.
• Body movement: While the nearest actor variable is valid, every .25 seconds:
1- Relative look rotation from the "Enemy" is calculated to the nearest actor.
1- Relative look rotation from the "Enemy" is calculated to the nearest actor.
2- I check if this values yaw is less than -55 or greater than 55.
3- If true, depending on the angle an animation from an array of 6 animations is selected.
4- Animations reorient the actor with root motion to face the nearest actor.
Height Problem
He is significantly taller than players, so he can't fit doorways and such.
Solution
Every 0.10 seconds, a sphere trace slightly in front of the characters head is cast. If this sphere trace hits anything then a boolean is set true.
On the animation blueprint I use the "Transform (Modify) bone" node on spine and neck bones to create a procedural leaning forward animation. Which is applied over the currently playing animations if the boolean is true.
The model is a customized MetaHuman in Blender by me.