After spending quite a bit of time writing code to allow characters to find other characters, determine line of sight, etc., I stumbled upon UPawnSensingComponent. I’m now in the process of throwing away what I’ve written to leverage this built-in functionality instead.
I added a pawn sensing component to my character:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Awareness)
TSubobjectPtr<class UPawnSensingComponent> PawnSensing;
I’m hitting problems when it comes time specify the OnSeePawn delegate and the OnHearNoise delegate. I tried following the instructions at https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Delegates/index.html and tried adding this to my constructor:
FSharedRef< FHearNoiseDelegate > HearNoiseDelegate( new FHearNoiseDelegate() );
PawnSensing->OnHearNoise(&AEnemyCharacter::OnHearNoise);
but I get this error:
EnemyCharacter.cpp:11:5: error: no template named 'FSharedRef'; did you mean 'TSharedRef'?
FSharedRef< FHearNoiseDelegate > HearNoiseDelegate( new FHearNoiseDelegate() );
The example code shows using FSharedRef. Is that a typo, or is there a header I need to include? Better yet, does anybody have an example of registering the OnHearNoise and/or OnSeePawn delegates, or something a little more in-depth on UE4’s delegates?
Thanks!