Table of contents
- Overview
- Advanced Sight System
- Advanced Sight Component
- Advanced Sight Data
- Advanced Sight Target
- Advanced Sight Target Component
- Advanced Sight Team Component
- Advanced Sight Visibility Point Component
Overview
Advanced sight system is a single instance system that processes the data fetched from agents thanks to the assisting components. Using single instance system helps to ensure that system can store all relevant data locally and in an efficient, cache friednly manner. The user facing API is very user friendly and easy to understand, doesn’t require any direct interaction with the underlying system and is exposed to blueprints to enpower blueprint only projects.
The design of the system is based on many reference games that use some sort of sight and stealth systems. Here are some of them:
- Legends of Zelda: Breath of the Wild
- Legends of Zelda: Tears of the Kingdom
- Deathloop
- Deus Ex: Human Revolution
- Dishonored 1 and 2
- Many, many more…
Here is a high level graph explaining the flow of the system together with broadcasted events:
Advanced Sight System
This is a UTickableWorldSubsystem
subclass. This means it’s created automatically by the engine, no explicit initialization is necessary. This class is mostly invisible to the end user since all communication with this class is available through UAdvancedSightComponent
.
Because this class is executing majority of the logic, it has a performance trace marker inside meaning it’s very easy to inspect the actual performance of the system using i.e. Unreal Insights
tool. The marker’s name is UAdvancedSightSystem::Tick
.
Advanced Sight Component
This is an actor component that should be attached to an AAIController
based classes. It’s used to communicate with the UAdvancedSightSystem
class, has properties allowing user to define appropriate data, blueprint exposed functions and events.
Advanced Sight Data
This is a data asset class that is used to define sight data. It’s used by UAdvancedSightComponent
.
Advanced Sight Target
This is an interface that must be implemented on any actor that should be perceivable by the owner of the advanced sight component. It requires user to implement a single function, GetVisibilityPointComponents
which is then called by the advanced sight target component and cached.
Advanced Sight Target Component
This is an actor component that must be attached to an actor that should be perceivable by the owner of advanced sight component. There is nothing exposed to the end user by this component. It is used only to fetch visibility points and cache the result so the advanced sight system doesn’t need to call a blueprint implementable events during tick which costs a lot of time.
Advanced Sight Team Component
This is an actor component that allows to define a FGenericTeamId
for an actor without requirement of implementing the C++ only interface. This interface is implemented on a AdvancedSightCharacter
however due the fact that some projects already use different character base class, this way they don’t need to change their inheritance hierarchy and can simply attach this component to the existing character.
Advanced Sight Visibility Point Component
This is a scene component that is used for the sight checks. It provides the location for the sight trace as well as custom Gain Rate
which can be set to an arbitrary value between 0.0 and MAX_FLOAT. The value of Gain Rate
is then used to multiply gain making actor perceived faster (if the value is greater than 1.0) or slower (if the value is lower than 1.0). This is mostly to simulate bigger body parts being perceived easier than smaller body parts.