Fixed Multiple Main Waypoints Becoming Focused When Looking at Just One

This commit is contained in:
Rafal Swierczek 2023-11-26 23:59:53 +00:00
parent c51f2ab7b6
commit 797653132e
7 changed files with 20 additions and 10 deletions

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:d3943e1a064276d17b897a7a10a3c42a35c75d6c02117bd1ea962544f3576a9b oid sha256:68499c0acedf4bd43fa13b5244a3900ad9850ff62e15ac85b1e337859200d06d
size 654898 size 654847

Binary file not shown.

View File

@ -46,6 +46,7 @@ void ACheckpointClass::Tick(float DeltaTime)
void ACheckpointClass::Destroyed() void ACheckpointClass::Destroyed()
{ {
if (WaypointActor) WaypointActor->Destroy(); if (WaypointActor) WaypointActor->Destroy();
Super::Destroyed();
} }

View File

@ -22,7 +22,7 @@ void AWaypointActor::SetupWaypoint_Implementation(UTexture2D* Icon, const FStrin
ScalingY_Intercept = ScaleAtMaxDist - (MaxDist * ScalingMagnitude); ScalingY_Intercept = ScaleAtMaxDist - (MaxDist * ScalingMagnitude);
MiniWaypoint = CreateWidget<UMiniWaypoint>(GetWorld(), MiniWaypointClass); MiniWaypoint = CreateWidget<UMiniWaypoint>(GetWorld(), MiniWaypointClass);
MiniWaypoint->AddToViewport(1); MiniWaypoint->AddToViewport(0);
MiniWaypoint->WorldLoc = this->GetActorLocation(); MiniWaypoint->WorldLoc = this->GetActorLocation();
MiniWaypoint->PlayerController = GetWorld()->GetFirstPlayerController(); MiniWaypoint->PlayerController = GetWorld()->GetFirstPlayerController();
MiniWaypoint->SetIcon(Icon); MiniWaypoint->SetIcon(Icon);
@ -51,7 +51,7 @@ bool AWaypointActor::SightCheck()
ObjectQueryParams.AddObjectTypesToQuery(ECollisionChannel::ECC_GameTraceChannel2); ObjectQueryParams.AddObjectTypesToQuery(ECollisionChannel::ECC_GameTraceChannel2);
FVector LT_Start = PlayersCam->GetComponentLocation(); FVector LT_Start = PlayersCam->GetComponentLocation();
FVector LT_End = LT_Start + (PlayersCam->GetForwardVector() * WaypointFocusDistance); FVector LT_End = LT_Start + (PlayersCam->GetForwardVector() * WaypointFocusDistance);
if (GetWorld()->LineTraceSingleByObjectType(OutHit, LT_Start, LT_End, ObjectQueryParams)) return true; if (GetWorld()->LineTraceSingleByObjectType(OutHit, LT_Start, LT_End, ObjectQueryParams) && OutHit.GetActor()->GetUniqueID() == this->GetUniqueID()) return true;
return false; return false;
} }
@ -72,3 +72,10 @@ void AWaypointActor::UpdateScaleAndRotation()
SetActorScale3D(FVector(1.f, S, S)); SetActorScale3D(FVector(1.f, S, S));
} }
void AWaypointActor::Destroyed()
{
if (IsValid(MiniWaypoint)) MiniWaypoint->RemoveFromParent();
Super::Destroyed();
}

View File

@ -47,6 +47,8 @@ protected:
UFUNCTION(BlueprintImplementableEvent) UFUNCTION(BlueprintImplementableEvent)
void UpdateVisibility(bool IsVisible); void UpdateVisibility(bool IsVisible);
void Destroyed() override;
public: public:
// Sets default values for this actor's properties // Sets default values for this actor's properties
AWaypointActor(); AWaypointActor();