Add properties and methods to know when attack the player
This commit is contained in:
parent
4a7119aecf
commit
52b996d3f6
BIN
Content/Legumix/Ennemy/MeleeEnemy/BB_MeleeEnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/MeleeEnemy/BB_MeleeEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/MeleeEnemy/BTTask_FindPlayer.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/MeleeEnemy/BTTask_FindPlayer.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/MeleeEnemy/BT_MeleeEnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/MeleeEnemy/BT_MeleeEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
@ -5,6 +5,7 @@
|
|||||||
ALMEnemy::ALMEnemy()
|
ALMEnemy::ALMEnemy()
|
||||||
{
|
{
|
||||||
PrimaryActorTick.bCanEverTick = true;
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
EnemyState = EEnemyState::EES_Chasing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ALMEnemy::BeginPlay()
|
void ALMEnemy::BeginPlay()
|
||||||
@ -12,6 +13,11 @@ void ALMEnemy::BeginPlay()
|
|||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
ALMMeleeEnemy::ALMMeleeEnemy()
|
ALMMeleeEnemy::ALMMeleeEnemy()
|
||||||
{
|
{
|
||||||
PrimaryActorTick.bCanEverTick = true;
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
AttackingRadius = 100.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ALMMeleeEnemy::BeginPlay()
|
void ALMMeleeEnemy::BeginPlay()
|
||||||
@ -22,4 +23,3 @@ void ALMMeleeEnemy::SetupPlayerInputComponent(UInputComponent* PlayerInputCompon
|
|||||||
{
|
{
|
||||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,13 @@
|
|||||||
#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
|
||||||
{
|
{
|
||||||
@ -18,4 +25,18 @@ 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")
|
||||||
|
double AttackingRadius;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user