Compare commits
3 Commits
ba0243bd65
...
5e0433905f
Author | SHA1 | Date |
---|---|---|
baz | 5e0433905f | |
baz | a43ec2c068 | |
baz | fdfa37a346 |
|
@ -8,6 +8,8 @@
|
||||||
#include "BehaviorTree/BehaviorTree.h"
|
#include "BehaviorTree/BehaviorTree.h"
|
||||||
#include "BehaviorTree/BlackboardComponent.h"
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
#include "BehaviorTree/BlackboardData.h"
|
#include "BehaviorTree/BlackboardData.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
#include "UI/EnemyHealthbarUserWidget.h"
|
#include "UI/EnemyHealthbarUserWidget.h"
|
||||||
|
|
||||||
#define COLLISION_WEAPON ECC_GameTraceChannel1
|
#define COLLISION_WEAPON ECC_GameTraceChannel1
|
||||||
|
@ -78,6 +80,23 @@ void AEnemyCharacter::BeginPlay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEnemyCharacter::Tick(float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
|
||||||
|
APlayerCharacter* PlayerCharacter = Cast<APlayerCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
|
||||||
|
if (PlayerCharacter && HealthbarWidgetComponent->GetWidget())
|
||||||
|
{
|
||||||
|
FVector ActorLocation = GetActorLocation();
|
||||||
|
|
||||||
|
UCameraComponent* PlayerCamera = PlayerCharacter->GetCameraComponent();
|
||||||
|
FVector PlayerLocation = PlayerCamera->GetComponentTransform().GetLocation();
|
||||||
|
|
||||||
|
FRotator rotation = UKismetMathLibrary::FindLookAtRotation(ActorLocation, PlayerLocation);
|
||||||
|
HealthbarWidgetComponent->SetWorldRotation(rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AEnemyCharacter::PlayOnFireAnimations()
|
void AEnemyCharacter::PlayOnFireAnimations()
|
||||||
{
|
{
|
||||||
Super::PlayOnFireAnimations();
|
Super::PlayOnFireAnimations();
|
||||||
|
|
|
@ -53,6 +53,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void PlayOnFireAnimations() override;
|
virtual void PlayOnFireAnimations() override;
|
||||||
|
|
||||||
|
|
|
@ -826,3 +826,8 @@ void APlayerCharacter::SetIsThrowing(bool bIsThrowing)
|
||||||
{
|
{
|
||||||
IsThrowing = bIsThrowing;
|
IsThrowing = bIsThrowing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UCameraComponent* APlayerCharacter::GetCameraComponent()
|
||||||
|
{
|
||||||
|
return CameraComponent;
|
||||||
|
}
|
||||||
|
|
|
@ -242,6 +242,8 @@ public:
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void SetIsThrowing(bool bIsThrowing);
|
void SetIsThrowing(bool bIsThrowing);
|
||||||
|
|
||||||
|
UCameraComponent* GetCameraComponent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CalculateHits(TArray<FHitResult>* hits, FVector* dir) override;
|
virtual void CalculateHits(TArray<FHitResult>* hits, FVector* dir) override;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ void UEnemyHealthbarUserWidget::BindOwner(AEnemyCharacter* NewOwner)
|
||||||
{
|
{
|
||||||
auto healthComponent = Owner->GetHealthComponent();
|
auto healthComponent = Owner->GetHealthComponent();
|
||||||
healthComponent->OnDamaged.BindUFunction(this, "UpdateHealthbar");
|
healthComponent->OnDamaged.BindUFunction(this, "UpdateHealthbar");
|
||||||
|
UpdateHealthbar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue