Compare commits

..

No commits in common. "2e59bb6e0e2c118c8ac4a07dc79117a453e5413a" and "03023ed4947c1d68b4948a07bd1717226c048afc" have entirely different histories.

4 changed files with 4 additions and 81 deletions

BIN
Content/Gamemode/BP_DefaultGamemode.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -37,6 +37,7 @@ void APickup::Tick(float DeltaSeconds)
if (currentDistance <= PickupMovementRange)
{
double speed = 400 / currentDistance;
UE_LOG(LogTemp, Warning, TEXT("The integer value is: %f"), speed);
FVector location = FMath::VInterpTo(actorLocation, playerLocation, DeltaSeconds, speed);
SetActorLocation(location);
}

View File

@ -3,62 +3,3 @@
#include "VampireGameMode.h"
#include "Kismet/GameplayStatics.h"
void AVampireGameMode::BeginPlay()
{
Super::BeginPlay();
PlayerCharacter = Cast<APlayerCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
PlayerController = Cast<AVampirePlayerController>(UGameplayStatics::GetPlayerController(PlayerCharacter, 0));
GetWorldTimerManager().SetTimer(SpawnEnemyTimerDelegate, this, &AVampireGameMode::SpawnEnemy, 1.0f, true);
}
void AVampireGameMode::SpawnEnemy()
{
FVector TopLeft, TopLeftDir;
FVector TopRight, TopRightDir;
FVector BottomLeft, BottomLeftDir;
FVector BottomRight, BottomRightDir;
FVector CenterPos, CenterDir;
FVector2d ViewportSize;
GEngine->GameViewport->GetViewportSize(ViewportSize);
PlayerController->DeprojectScreenPositionToWorld(0, 0, TopLeft, TopLeftDir);
PlayerController->DeprojectScreenPositionToWorld(ViewportSize.X, 0, TopRight, TopRightDir);
PlayerController->DeprojectScreenPositionToWorld(0, ViewportSize.Y, BottomLeft, BottomLeftDir);
PlayerController->DeprojectScreenPositionToWorld(ViewportSize.X, ViewportSize.Y, BottomRight, BottomRightDir);
PlayerController->DeprojectScreenPositionToWorld(ViewportSize.X / 2, ViewportSize.Y / 2, CenterPos, CenterDir);
FVector SpawnLocation;
switch (FMath::RandRange(0, 3))
{
case 0:
SpawnLocation = FMath::Lerp(TopLeft, TopRight, FMath::RandRange(0.0f, 1.0f));
break;
case 1:
SpawnLocation = FMath::Lerp(TopRight, BottomRight, FMath::RandRange(0.0f, 1.0f));
break;
case 2:
SpawnLocation = FMath::Lerp(BottomRight, BottomLeft, FMath::RandRange(0.0f, 1.0f));
break;
case 3:
SpawnLocation = FMath::Lerp(BottomLeft, TopLeft, FMath::RandRange(0.0f, 1.0f));
break;
default:
UE_LOG(LogTemp, Warning, TEXT("Something broke"));
break;
}
SpawnLocation.Z = PlayerCharacter->GetActorLocation().Z;
FTransform Transform;
Transform.SetLocation(SpawnLocation);
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
AEnemyCharacter* actor = GetWorld()->SpawnActor<AEnemyCharacter>(EnemyTemplate, Transform, SpawnParameters);
actor->SpawnDefaultController();
}

View File

@ -3,9 +3,6 @@
#pragma once
#include "CoreMinimal.h"
#include "EnemyCharacter.h"
#include "PlayerCharacter.h"
#include "VampirePlayerController.h"
#include "GameFramework/GameMode.h"
#include "VampireGameMode.generated.h"
@ -17,20 +14,4 @@ class VAMPIRES_API AVampireGameMode : public AGameMode
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly)
TSubclassOf<AEnemyCharacter> EnemyTemplate;
private:
APlayerCharacter* PlayerCharacter;
AVampirePlayerController* PlayerController;
FTimerHandle SpawnEnemyTimerDelegate;
protected:
virtual void BeginPlay() override;
UFUNCTION()
void SpawnEnemy();
};