SamSuka
CodeLikeMe
CodeLikeMe

patreon


Unreal Engine 5 C++ Tutorial - Turret #5 - Detect Enemies with Line traces

This is part 5 of the Turret system in unreal engine 5 using C++. Today, we are going to implement a way to detect enemy characters for the turret. This will be handled through a line-trace and an interface function names IsEnemy() which will be implemented in C++ on third person character class. If the HitResult of the line trace contains a Hit Actor and if that Hit Actor implements the interface function IsEnemy() and if this function returns true, the character will be detected by the turret as an enemy. After an enemy is detected, the turret will continue to aim towards the locked enemy character until it break line of sight. Once the line of sight is broken, the turret will return to normal sweeping behavior.



password=CodeLikeMe_DetectEnemies

Unreal Engine 5 C++ Tutorial - Turret #5 - Detect Enemies with Line traces

More Creators