Started Implementing Vision Link Functionality
This commit is contained in:
parent
91052ed5ac
commit
81a8c2ae44
@ -38,7 +38,14 @@ void AVisionLink::SendOutPingPulse()
|
||||
UpdatePulsesRemaining(NumOfPingPulsesLeftInThisCycle);
|
||||
if (NumOfPingPulsesLeftInThisCycle < 0) return;
|
||||
|
||||
// THIS IS WHERE I"LL PUT PING PULSE LOGIC
|
||||
FActorSpawnParameters SpawnParams;
|
||||
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
FVector SpawnLoc = (GetActorLocation() - EquippedOffset) + EnemyLOSTestActor.GetDefaultObject()->SpawnOffset;
|
||||
|
||||
AActor* LOSTestActor = GetWorld()->SpawnActor<AActor>(EnemyLOSTestActor, SpawnLoc, GetActorRotation(), SpawnParams);
|
||||
TArray<AActor> EmptyActorArray;
|
||||
Cast<AVisionLinkEnemyLOSTest>(LOSTestActor)->TestLOS(EmptyActorArray, GetOwner());
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("Ping Pulse!"));
|
||||
GetWorld()->GetTimerManager().SetTimer(PulseHandle, this, &AVisionLink::SendOutPingPulse, TimeInbetweenPingPulses, false);
|
||||
PlayPingPulseAnim(TimeInbetweenPingPulses);
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "VisionLinkEnemyLOSTest.h"
|
||||
#include "EndlessVendetta/GadgetSystem/ReconGadget.h"
|
||||
#include "VisionLink.generated.h"
|
||||
|
||||
@ -32,6 +33,9 @@ protected:
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Vision Link")
|
||||
int NumberOfPingPulses = 1;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Vision Link")
|
||||
TSubclassOf<AVisionLinkEnemyLOSTest> EnemyLOSTestActor;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category = "Vision Link")
|
||||
float CooldownLength;
|
||||
|
@ -0,0 +1,70 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "VisionLinkEnemyLOSTest.h"
|
||||
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
|
||||
// Sets default values
|
||||
AVisionLinkEnemyLOSTest::AVisionLinkEnemyLOSTest()
|
||||
{
|
||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void AVisionLinkEnemyLOSTest::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void AVisionLinkEnemyLOSTest::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
void AVisionLinkEnemyLOSTest::TestLOS(TArray<AActor> EnemiesInLink, AActor* LOSActor)
|
||||
{
|
||||
// Get all overlapping Actors
|
||||
UBoxComponent* CollisionBox = Cast<UBoxComponent>(GetComponentByClass(UBoxComponent::StaticClass()));
|
||||
if (!IsValid(CollisionBox))
|
||||
{
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
TArray<AActor*> OverlappingEnemies;
|
||||
CollisionBox->GetOverlappingActors(OverlappingEnemies);
|
||||
if (OverlappingEnemies.IsEmpty())
|
||||
{
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < OverlappingEnemies.Num(); i++)
|
||||
{
|
||||
// Overlapping Enemies Array should only contain enemies which aren't already in the link
|
||||
if (!OverlappingEnemies[i]->ActorHasTag(FName("Enemy")) || EnemiesInLink.Contains(OverlappingEnemies[i])) OverlappingEnemies.RemoveAt(i);
|
||||
}
|
||||
if (OverlappingEnemies.IsEmpty())
|
||||
{
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
for (AActor* Enemy : OverlappingEnemies)
|
||||
{
|
||||
FRotator LookAtRotation = UKismetMathLibrary::FindLookAtRotation(LOSActor->GetActorLocation(), Enemy->GetActorLocation());
|
||||
UE_LOG(LogTemp, Warning, TEXT("Look at Rotation: %f"), LookAtRotation.Yaw);
|
||||
}
|
||||
|
||||
Destroy();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "VisionLinkEnemyLOSTest.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class ENDLESSVENDETTA_API AVisionLinkEnemyLOSTest : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Vision Link")
|
||||
FVector SpawnOffset = FVector(0, 0, 0 );
|
||||
|
||||
// Sets default values for this actor's properties
|
||||
AVisionLinkEnemyLOSTest();
|
||||
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
void TestLOS(TArray<AActor> EnemiesInLink, AActor* LOS_Actor);
|
||||
};
|
Loading…
Reference in New Issue
Block a user