Hi guys!
I’m currently trying to trigger a camera shake on the Sentinal character when the Shrouded character comes nearby. Currently the ‘DetectNearbyShrouded’ method is called every tick which gets the Sentinal location and Shrouded location then compares them using FVector::Distance before using a if statement to say if they’re within a range of 200 start the camera shake. I think maybe I am casting wrong when getting the Shrouded’s location? I’ve already tried using a Box collision attached to the Sentinal combined with OnBeginOverlap and didn’t have much luck.
Any help would be appreciated
Sentinal.h
UFUNCTION()
void DetectNearbyShrouded(AActor* OtherActor);
Sentinal.cpp
void ASentinal::DetectNearbyShrouded(AActor* OtherActor)
{
FVector SentinalLoc;
SentinalLoc = GetActorLocation();
AShrouded* ShroudedReference = Cast<AShrouded>(OtherActor);
FVector ShroudedLoc = ShroudedReference->GetActorLocation();
float Distance = FVector::Distance(SentinalLoc, ShroudedLoc);
if (Distance > 200.0f)
{
GetWorld()->GetFirstPlayerController()->PlayerCameraManager->StartMatineeCameraShake(ShakeCamera, 6.0f);
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, TEXT("Shake"));
}
else {
GetWorld()->GetFirstPlayerController()->PlayerCameraManager->StopAllCameraShakes();
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, TEXT("Stop Shake"));
}
}