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