17.Creating the HUD Blueprint
BatteryCollectorGameMode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 |
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/GameMode.h"
#include "BatteryCollectorGameMode.generated.h"
UCLASS(minimalapi)
class ABatteryCollectorGameMode : public AGameMode
{
GENERATED_BODY()
public:
ABatteryCollectorGameMode();
virtual void Tick(float DeltaTime) override;
//Returns power needed to win - needed for the HUD
UFUNCTION(BlueprintPure, Category = "Power")
float GetPowerToWin() const;
virtual void BeginPlay() override;
protected:
/**The rate at which the character loses power */
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected = "true"))
float DecayRate;
/**The power needed to win the game*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected = "true"))
float PowerToWin;
/**The widget class to use for our HUD screen*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected = "true"))
TSubclassOf<class UUserWidget> HUDWidgetClass;
//The instance of the HUD
/***/
UPROPERTY()
class UUserWidget* CurrentWidget;
}; |
cs |
BatteryCollectorGameMode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13 |
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "BatteryCollector.h"
#include "BatteryCollectorGameMode.h"
#include "BatteryCollectorCharacter.h"
#include "Kismet/GameplayStatics.h"
#include "Blueprint/UserWidget.h"
float ABatteryCollectorGameMode::GetPowerToWin() const{
return PowerToWin;
}
|
cs |
Get Player Character는 유일하게 파워에 대한 정보를 갖고있는 노드
BatteryCollector 캐릭터로 형변환해주어야한다
'프로그래밍 > Unreal' 카테고리의 다른 글
[15]Battery Collector_플레이 상태별 spawn volume작동, 플레이어 입력차단, 캐릭터 레그돌효과 (0) | 2017.05.14 |
---|---|
[14]Battery Collector_player 상태 설정 (0) | 2017.05.13 |
[12]Battery Collector_UMG 활성화 (0) | 2017.05.11 |
[11]Battery Collector_particle추가 (0) | 2017.05.11 |
[10]Battery Collector_ power에 따른 속도, 색변화 (0) | 2017.05.11 |