Hi @fael097 -
The documentation for interfaces is here.
I don’t have time to verify it at the moment but it will probably have to be implemented on the class which contains the stimuli source of the target that the AI agent is observing. In your case, the player character class.
Just from looking at it you’ll have to probably do something like the following. Again, this is completely untested code it’s just a guideline to help you get started.
Include the interface header in your character’s .h file
#include "Perception/AISightTargetInterface.h"
Inherit from the interface for your character class
class YOURMODULE_API AMyCharacter : public ACharacter, public IAISightTargetInterface
Override the interface function in your character class’ .h and .cpp files
MyCharacter.h
virtual bool CanBeSeenFrom(const FVector& ObserverLocation, FVector& OutSeenLocation, int32& NumberOfLoSChecksPerformed, float& OutSightStrength, const AActor* IgnoreActor = nullptr, const bool* bWasVisible = nullptr, int32* UserData = nullptr) const override
MyCharacter.cpp
bool AMyCharacter::CanBeSeenFrom(const FVector& ObserverLocation, FVector& OutSeenLocation, int32& NumberOfLoSChecksPerformed, float& OutSightStrength, const AActor* IgnoreActor /** = nullptr */, const bool* bWasVisible /* = nullptr */, int32* UserData /* = nullptr */) const
{
// For each LoS check you want to perform
// Perform the check
// Increment NumberOfLosChecksPerformed
// Increase the OutSightStrength based on a heuristic you determine
// Check to see if you can early out of the loop if you decide the strength check is high enough
// Return true/false if you determine the actor can be seen
}
I don’t think the gameplay debugger will capture and display the information regarding your additional LoS traces since they are being done in your character class, but I would expect it to at least capture the strength.
If you wanted to display that additional trace information in the visual debugger I think you’d either have to create a new sense config from UAISenseConfig_Sight and override the DescribeSelfToGameplayDebugger function, or add another FGameplayDebuggerCategory and register it.
Godspeed developer