Add projectiles to range enemy (trigger by overlap for now)
This commit is contained in:
parent
e58d3eb0db
commit
b4737e2669
BIN
Content/Legumix/Ennemy/RangeEnemy/AI/EQS_RangeEnnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/RangeEnemy/AI/EQS_RangeEnnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/RangeEnemy/AI/Task/BTTask_RangeAttack.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/RangeEnemy/AI/Task/BTTask_RangeAttack.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/RangeEnemy/Projectile/BP_Projectile.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/RangeEnemy/Projectile/BP_Projectile.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Levels/LVL_GYM_00.umap
(Stored with Git LFS)
BIN
Content/Legumix/Levels/LVL_GYM_00.umap
(Stored with Git LFS)
Binary file not shown.
@ -1,33 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "Enemy/DistantEnemy/Projectile/BPProjectile.h"
|
|
||||||
#include "Components/SphereComponent.h"
|
|
||||||
|
|
||||||
// Sets default values
|
|
||||||
ABPProjectile::ABPProjectile()
|
|
||||||
{
|
|
||||||
PrimaryActorTick.bCanEverTick = true;
|
|
||||||
ProjectileCollision = CreateDefaultSubobject<USphereComponent>(TEXT("ProjectileCollision"));
|
|
||||||
SetRootComponent(ProjectileCollision);
|
|
||||||
// Collisions :
|
|
||||||
ProjectileCollision->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
|
|
||||||
ProjectileCollision->SetNotifyRigidBodyCollision(true);
|
|
||||||
ProjectileCollision->BodyInstance.SetCollisionProfileName(TEXT("BlockAllDynamic"));
|
|
||||||
|
|
||||||
ProjectileMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ProjectileMesh"));
|
|
||||||
ProjectileMesh->SetupAttachment(ProjectileCollision);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ABPProjectile::BeginPlay()
|
|
||||||
{
|
|
||||||
Super::BeginPlay();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ABPProjectile::Tick(float DeltaTime)
|
|
||||||
{
|
|
||||||
Super::Tick(DeltaTime);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "Enemy/DistantEnemy/Projectile/LMProjectile.h"
|
||||||
|
|
||||||
|
// #include "VectorTypes.h"
|
||||||
|
#include "Components/SphereComponent.h"
|
||||||
|
#include "GameFramework/ProjectileMovementComponent.h"
|
||||||
|
// #include "Player/LMHealthComponent.h"
|
||||||
|
// #include "Player/LMHitBox.h"
|
||||||
|
// #include "Player/LMPlayer.h"
|
||||||
|
|
||||||
|
// Sets default values
|
||||||
|
ALMProjectile::ALMProjectile()
|
||||||
|
{
|
||||||
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
ProjectileCollision = CreateDefaultSubobject<USphereComponent>(TEXT("ProjectileCollision"));
|
||||||
|
SetRootComponent(ProjectileCollision);
|
||||||
|
// // Collisions :
|
||||||
|
ProjectileCollision->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||||
|
ProjectileCollision->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
|
||||||
|
// ProjectileCollision->OnComponentBeginOverlap.AddDynamic(this, &ALMProjectile::OnSphereOverlap);
|
||||||
|
|
||||||
|
ProjectileMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ProjectileMesh"));
|
||||||
|
ProjectileMesh->SetupAttachment(ProjectileCollision);
|
||||||
|
|
||||||
|
ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovement"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
void ALMProjectile::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
InitialLocation = GetActorLocation();
|
||||||
|
|
||||||
|
}
|
||||||
|
// TO DEBUG OR ERASE
|
||||||
|
// void ALMProjectile::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
|
// UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||||
|
// {
|
||||||
|
// if(GEngine)
|
||||||
|
// {
|
||||||
|
// GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Yellow, "1Damage");
|
||||||
|
// }
|
||||||
|
// if(ALMPlayer* Player = Cast<ALMPlayer>(OtherActor))
|
||||||
|
// {
|
||||||
|
// if(GEngine)
|
||||||
|
// {
|
||||||
|
// GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Yellow, "2Damage");
|
||||||
|
// }
|
||||||
|
// if (ULMHitBox* HitBox = Cast<ULMHitBox>(OtherComp))
|
||||||
|
// {
|
||||||
|
// Player->GetHealthComponent()->TakeDamage(AttackingDamage);
|
||||||
|
// if(GEngine)
|
||||||
|
// {
|
||||||
|
// GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Yellow, "3Damage");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// Destroy();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Called every frame
|
||||||
|
void ALMProjectile::Tick(float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
if(FVector::Distance(GetActorLocation(), InitialLocation) > MaxRange)
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,33 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "GameFramework/Actor.h"
|
|
||||||
#include "BPProjectile.generated.h"
|
|
||||||
|
|
||||||
class UStaticMeshComponent;
|
|
||||||
class USphereComponent;
|
|
||||||
|
|
||||||
UCLASS()
|
|
||||||
class LEGUMEMIX_API ABPProjectile : public AActor
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
ABPProjectile();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void BeginPlay() override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual void Tick(float DeltaTime) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
|
|
||||||
TObjectPtr<USphereComponent> ProjectileCollision;
|
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
|
|
||||||
TObjectPtr<UStaticMeshComponent> ProjectileMesh;
|
|
||||||
|
|
||||||
};
|
|
@ -0,0 +1,46 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "GameFramework/Actor.h"
|
||||||
|
#include "LMProjectile.generated.h"
|
||||||
|
|
||||||
|
class UStaticMeshComponent;
|
||||||
|
class USphereComponent;
|
||||||
|
class UProjectileMovementComponent;
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class LEGUMEMIX_API ALMProjectile : public AActor
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
ALMProjectile();
|
||||||
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
// UFUNCTION(BlueprintCallable)
|
||||||
|
// void OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
|
||||||
|
float AttackingDamage = 15.f;
|
||||||
|
|
||||||
|
private:
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
|
||||||
|
TObjectPtr<USphereComponent> ProjectileCollision;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
|
||||||
|
TObjectPtr<UStaticMeshComponent> ProjectileMesh;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
|
||||||
|
TObjectPtr<UProjectileMovementComponent> ProjectileMovement;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta = (AllowPrivateAccess = true))
|
||||||
|
float MaxRange = 1500.f;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
|
||||||
|
FVector InitialLocation;
|
||||||
|
};
|
@ -113,6 +113,8 @@ public:
|
|||||||
USkeletalMeshComponent* GetArmsBP();
|
USkeletalMeshComponent* GetArmsBP();
|
||||||
USkeletalMeshComponent* GetArms();
|
USkeletalMeshComponent* GetArms();
|
||||||
|
|
||||||
|
FORCEINLINE ULMHealthComponent* GetHealthComponent() const { return HealthComponent; }
|
||||||
|
|
||||||
UPROPERTY(BlueprintCallable, BlueprintAssignable, Category=Legumix)
|
UPROPERTY(BlueprintCallable, BlueprintAssignable, Category=Legumix)
|
||||||
FOnRequestUnpauseSignature OnRequestedUnpause;
|
FOnRequestUnpauseSignature OnRequestedUnpause;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user