Compare commits
No commits in common. "e2e32e009234a8c66c16dad11aeeba6582899c99" and "95a065f208278507688eabf39ad689caefb9394b" have entirely different histories.
e2e32e0092
...
95a065f208
|
@ -1,22 +1,42 @@
|
|||
#include "HealthPickup.h"
|
||||
#include "HealthPickup.h"
|
||||
#include "PlayerCharacter.h"
|
||||
|
||||
|
||||
// Sets default values
|
||||
AHealthPickup::AHealthPickup()
|
||||
{
|
||||
// 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;
|
||||
|
||||
StaticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMesh"));
|
||||
StaticMeshComponent->SetupAttachment(RootComponent);
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void AHealthPickup::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
StaticMeshComponent->SetWorldLocation(this->GetActorLocation());
|
||||
StartingLocation = this->GetActorLocation();
|
||||
StaticMeshComponent->SetCollisionProfileName(FName("NoCollision"));
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void AHealthPickup::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
if (StaticMeshComponent)
|
||||
{
|
||||
// Rotate Weapon in desired direction
|
||||
StaticMeshComponent->AddLocalRotation((SpinRotation * RotationSpeed) * DeltaTime);
|
||||
|
||||
// Bob weapon up and down
|
||||
const float Time = GetWorld()->GetRealTimeSeconds();
|
||||
const float Sine = FMath::Abs(FMath::Sin(Time * MovementSpeed));
|
||||
StaticMeshComponent->SetRelativeLocation(StartingLocation + ((MovementDirection * Sine) * MovementDistance));
|
||||
}
|
||||
}
|
||||
|
||||
void AHealthPickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "StaticMeshPickup.h"
|
||||
#include "Pickup.h"
|
||||
#include "HealthPickup.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class NAKATOMI_API AHealthPickup : public AStaticMeshPickup
|
||||
class NAKATOMI_API AHealthPickup : public APickup
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
@ -12,6 +12,28 @@ public:
|
|||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
float Health = 20.0f;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
UStaticMeshComponent* StaticMeshComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
FVector MovementDirection = FVector(0.0f, 0.0f, 1.0f);
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
float MovementDistance = 1.0f;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
float MovementSpeed = 1.0f;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
FRotator SpinRotation = FRotator(0.0, 1.0f, 0.0f);
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
float RotationSpeed = 50.0f;
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
FVector StartingLocation;
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
AHealthPickup();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
#include "LevelKeyPickup.h"
|
||||
|
||||
#include "NakatomiGameInstance.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
|
|
|
@ -3,20 +3,17 @@
|
|||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "StaticMeshPickup.h"
|
||||
#include "Pickup.h"
|
||||
#include "LevelKeyPickup.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class NAKATOMI_API ALevelKeyPickup : public AStaticMeshPickup
|
||||
class NAKATOMI_API ALevelKeyPickup : public APickup
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
ALevelKeyPickup() { }
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "StaticMeshPickup.h"
|
||||
|
||||
AStaticMeshPickup::AStaticMeshPickup()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
StaticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMesh"));
|
||||
StaticMeshComponent->SetupAttachment(RootComponent);
|
||||
}
|
||||
|
||||
void AStaticMeshPickup::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
StaticMeshComponent->SetWorldLocation(this->GetActorLocation());
|
||||
StartingLocation = this->GetActorLocation();
|
||||
StaticMeshComponent->SetCollisionProfileName(FName("NoCollision"));
|
||||
}
|
||||
|
||||
void AStaticMeshPickup::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
if (StaticMeshComponent)
|
||||
{
|
||||
// Rotate Weapon in desired direction
|
||||
StaticMeshComponent->AddLocalRotation((SpinRotation * RotationSpeed) * DeltaTime);
|
||||
|
||||
// Bob weapon up and down
|
||||
const float Time = GetWorld()->GetRealTimeSeconds();
|
||||
const float Sine = FMath::Abs(FMath::Sin(Time * MovementSpeed));
|
||||
StaticMeshComponent->SetRelativeLocation(StartingLocation + ((MovementDirection * Sine) * MovementDistance));
|
||||
}
|
||||
}
|
||||
|
||||
void AStaticMeshPickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||
{
|
||||
Super::OnOverlapBegin(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Pickup.h"
|
||||
#include "StaticMeshPickup.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class NAKATOMI_API AStaticMeshPickup : public APickup
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
UStaticMeshComponent* StaticMeshComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
FVector MovementDirection = FVector(0.0f, 0.0f, 1.0f);
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
float MovementDistance = 1.0f;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
float MovementSpeed = 1.0f;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
FRotator SpinRotation = FRotator(0.0, 1.0f, 0.0f);
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
float RotationSpeed = 50.0f;
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
FVector StartingLocation;
|
||||
|
||||
public:
|
||||
|
||||
AStaticMeshPickup();
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
virtual void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) override;
|
||||
};
|
Loading…
Reference in New Issue