I’m having this weird issue where my TickComponent function is not calling other member functions in the same class.
The following works fine:
void UHealthComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (!HealthBarWidget) return;
HealthBarWidget->SetHealth(HealthPoints);
HealthBarWidget->SetMaximumHealth(MaximumHealthPoints);
ElapsedTime += DeltaTime;
if (ElapsedTime > 2.f)
{
HealthPoints -= 100;
ElapsedTime = 0;
}
}
But the following doesn’t:
void UHealthComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (!HealthBarWidget) return;
DrainHealth(DeltaTime);
UpdateWidget();
}
void UHealthComponent::DrainHealth(float deltaTime)
{
ElapsedTime += deltaTime;
if (ElapsedTime > 2.f)
{
MutateHealth(-100);
ElapsedTime = 0;
}
}
void UHealthComponent::UpdateWidget()
{
if (!HealthBarWidget) return;
HealthBarWidget->SetHealth(HealthPoints);
HealthBarWidget->SetMaximumHealth(MaximumHealthPoints);
}
void UHealthComponent::MutateHealth(int32 deltaHealthPoints)
{
HealthPoints -= deltaHealthPoints;
}
What’s really weird is that the debugger will hit the breakpoint where the function is called but it won’t actually step into the function. The functions just aren’t getting called at all.
Can anyone point me in the right direction? Also: they all have the same access modifier: protected
.