Add Perception to range enemy and rework enemy C++ class

This commit is contained in:
Emilie Schott 2025-03-21 01:38:52 +01:00
parent d221a9ffcc
commit b1f139426d
12 changed files with 21 additions and 42 deletions

BIN
Content/Legumix/Ennemy/E_EnemyState.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Legumix/Levels/LVL_00.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -5,7 +5,6 @@
ALMEnemy::ALMEnemy() ALMEnemy::ALMEnemy()
{ {
PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bCanEverTick = true;
EnemyState = EEnemyState::EES_Chasing;
AttackingRadius = 100.f; AttackingRadius = 100.f;
AttackingDamage = 0.f; AttackingDamage = 0.f;
} }
@ -22,11 +21,6 @@ void ALMEnemy::Attack(const APawn* TargetedPawn)
GEngine->AddOnScreenDebugMessage(1, 2.f, FColor::Cyan, Debug); GEngine->AddOnScreenDebugMessage(1, 2.f, FColor::Cyan, Debug);
} }
double ALMEnemy::GetDistanceToTarget(const AActor* TargetedActor)
{
return (TargetedActor->GetActorLocation() - GetActorLocation()).Length();
}
void ALMEnemy::Tick(float DeltaTime) void ALMEnemy::Tick(float DeltaTime)
{ {
Super::Tick(DeltaTime); Super::Tick(DeltaTime);

View File

@ -6,13 +6,6 @@
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
#include "LMEnemy.generated.h" #include "LMEnemy.generated.h"
UENUM(BlueprintType)
enum class EEnemyState : uint8
{
EES_Chasing UMETA(DisplayName = "Chasing"),
EES_Attacking UMETA(DisplayName = "Attacking")
};
UCLASS() UCLASS()
class LEGUMEMIX_API ALMEnemy : public ACharacter class LEGUMEMIX_API ALMEnemy : public ACharacter
{ {
@ -31,23 +24,12 @@ public:
protected: protected:
virtual void BeginPlay() override; virtual void BeginPlay() override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
EEnemyState EnemyState;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
double AttackingRadius; double AttackingRadius;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
float AttackingDamage; float AttackingDamage;
/**
* Returns the distance between the enemy and a target.
* @param TargetedActor
* @returns the distance
*/
UFUNCTION(BlueprintCallable, Category="Legumix", meta=(ReturnDisplayName="Distance", DefaultToSelf="TargetedActor"))
double GetDistanceToTarget(const AActor* TargetedActor);
/** /**
* Performs an attack on the targeted pawn * Performs an attack on the targeted pawn
* @param TargetedPawn * @param TargetedPawn