Why PlaySound2D does work when press a key but not when the event is triggered?

This is the UI code:

PlaySound2D does work when a key is pressed but not when the event is triggered.

Enyone knows why?

The widget is a component of the HUD class.

This is how the event is triggered (for test purposes only):

.h


UPROPERTY(ReplicatedUsing=NotifyToClientEvent)
bool bHealth=false;
UFUNCTION()
void NotifyToClientEvent();

.cpp

//-----------------------------------------------------------------------------
void UHealthComponent::NotifyToClientEvent()
{
	if (OnHealthChangeClientEvent.IsBound())	
		OnHealthChangeClientEvent.Broadcast( GetHealthValue() );	
}
//-----------------------------------------------------------------------------
void UHealthComponent::OnTakeAnyDamage(
	AActor* DamagedActor, float Damage, const class UDamageType* DamageType,
	class AController* InstigatedBy, AActor* DamageCauser)
{

	bHealth = !bHealth;
}
//-----------------------------------------------------------------------------

Any idea?
Thank you so much!!

you have an Is valid condition and 3 Ifs. have you tried to print something on false results and at the beginning of the event to find out where is failing?

1 Like

Hi
Yes, I have this checks… all they are valid in all cases

I added this too (As you said)… but it seem the logic is fine. It does works… but no sound is played.

The event is executed in all cases too… It can be seen in visual debugger (in the video).

Thanks for your help

HI @eldany.uy

I think we fund the problem

Unfortunately the solution seem to be bugged

Anyway i want thank you for your help!! :heart:

1 Like

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