Getter value not being pulled through


I am trying to increase my score when an overlap event occurs, the code is called correctly but the value contained within the overlapped actor is not being pulled through.

For example, I spawn a powerup into the scene, it’s powerupvalue is set to 50


When the overlap event happens, I call the following line of code:

void APaddle::BeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
	if ((OtherActor != nullptr) && (OtherActor != this) && (OtherComp != nullptr))
		APowerup* const CollidedPowerup = Cast<APowerup>(OtherActor);
		if (CollidedPowerup)
			UE_LOG(LogTemp, Warning, TEXT("Current Score: %d"), GetScore());

The destroy part of the code works, but the value of the log always returns 0.
If I run the following line of code within this snippet of code:

UE_LOG(LogTemp, Warning, TEXT("Powerup Score: %d"), CollidedPowerup->GetPowerupValue());

The value returned is also 0, but if I spawn a powerup and check it’s properties in Details tab as mentioned above, I can see that the powerup value is set to 50.

Why is this happening?

Just an update to say the CurrentScore is successfully updated on my player actor when I check the Details tab, it just seems to be in the editor it is not updating

I’ve been trying to troubleshoot why this is not working and I’m fairly certain its a bug/UI issue. I created a widget that keeps track of the score by using the GetScore() function. When I collect a powerup, the UI widget updates correctly, so it is only the editor which displays the incorrect value

I found out why this is not working, I was using the wrong formatting value. My CurrentScore variable is a float so I should have been using %f in the Text. %d is used for integers so if I change the line of code from

UE_LOG(LogTemp, Warning, TEXT("Current Score: %d"), GetScore());


UE_LOG(LogTemp, Warning, TEXT("Current Score: %f"), GetScore());

The Output Log displays the correct value, more information can be found on the Unreal Wiki below: