Create basic HUD
This commit is contained in:
parent
0d5858f421
commit
707728940a
BIN
Content/Player/BP_PlayerCharacter.uasset (Stored with Git LFS)
BIN
Content/Player/BP_PlayerCharacter.uasset (Stored with Git LFS)
Binary file not shown.
Binary file not shown.
|
@ -27,19 +27,19 @@ public:
|
|||
// Sets default values for this component's properties
|
||||
UEXPComponent();
|
||||
|
||||
UFUNCTION()
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void IncrementEXP(int value);
|
||||
|
||||
UFUNCTION()
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetCurrentEXP(int value);
|
||||
|
||||
UFUNCTION()
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
int GetCurrentEXP();
|
||||
|
||||
UFUNCTION()
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
int GetCurrentLevel();
|
||||
|
||||
UFUNCTION()
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void Reset();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -40,6 +40,16 @@ APlayerCharacter::APlayerCharacter()
|
|||
void APlayerCharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
if (PlayerHUD)
|
||||
{
|
||||
currentPlayerHUD = UUserWidget::CreateWidgetInstance(*GetWorld(), PlayerHUD, FName("Player HUD"));
|
||||
|
||||
if (currentPlayerHUD)
|
||||
{
|
||||
currentPlayerHUD->AddToViewport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "WeaponInventoryComponent.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "PlayerCharacter.generated.h"
|
||||
|
||||
class UInputMappingContext;
|
||||
|
@ -46,9 +47,14 @@ public:
|
|||
|
||||
FVector2D PreviousMovementDirection = FVector2d(1.0f, 0.0f);
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TSubclassOf<UUserWidget> PlayerHUD = nullptr;
|
||||
|
||||
private:
|
||||
FTimerHandle GarlicTimerHandle;
|
||||
|
||||
UUserWidget* currentPlayerHUD = nullptr;
|
||||
|
||||
public:
|
||||
APlayerCharacter();
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "HUDWidget.h"
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "Components/ProgressBar.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "HUDWidget.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class VAMPIRES_API UHUDWidget : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
UProgressBar* EXPbar;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
UTextBlock* LevelBlock;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
UTextBlock* TimerBLock;
|
||||
|
||||
};
|
|
@ -10,7 +10,8 @@
|
|||
"LoadingPhase": "Default",
|
||||
"AdditionalDependencies": [
|
||||
"Engine",
|
||||
"AIModule"
|
||||
"AIModule",
|
||||
"UMG"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue