Tried to hide health bar after tank death

Started with FindComponentByClass, but got an error.

.cpp
#include “Tank.h”
#include “Components/WidgetComponent.h”
#include “Math/UnrealMathUtility.h”
#include “GameFramework/Actor.h”

void ATank::BeginPlay()
{
Super::BeginPlay();
CurrentHealth = 100;
Widget = FindComponentByClass UWidgetComponent ();
}

.h
#pragma once

#include “CoreMinimal.h”
#include “GameFramework/Actor.h”
#include “Tank.generated.h”

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FTankDelegate);
class UWidgetComponent;

private:
UWidgetComponent* Widget = nullptr;

Did you add UMG to your Build.cs?

1 Like

Thanks, that was the problem

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms