Changed checking method for SpawnPosition
This commit is contained in:
parent
f147527812
commit
35a1cd757b
@ -5,6 +5,7 @@
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Engine/World.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
|
||||
// Sets default values
|
||||
ALMSpawnPosition::ALMSpawnPosition()
|
||||
@ -23,7 +24,11 @@ bool ALMSpawnPosition::CanSpawn()
|
||||
void ALMSpawnPosition::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
AActor* Player = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);
|
||||
if (Player)
|
||||
{
|
||||
PlayerCamera = Player->FindComponentByClass<UCameraComponent>();
|
||||
}
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
@ -39,7 +44,7 @@ bool ALMSpawnPosition::IsPlayerVisible() const
|
||||
if (!Player) return false;
|
||||
|
||||
FVector Start = GetActorLocation();
|
||||
FVector End = Player->GetActorLocation();
|
||||
FVector End = PlayerCamera->GetComponentLocation();
|
||||
|
||||
FHitResult HitResult;
|
||||
FCollisionQueryParams Params;
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "LMSpawnPosition.generated.h"
|
||||
|
||||
class UCameraComponent;
|
||||
|
||||
UCLASS()
|
||||
class LEGUMEMIX_API ALMSpawnPosition : public AActor
|
||||
{
|
||||
@ -26,6 +28,9 @@ protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
virtual void EndCooldown();
|
||||
|
||||
UPROPERTY()
|
||||
UCameraComponent* PlayerCamera = nullptr;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
|
Reference in New Issue
Block a user