Ivan3z
(Ivan3z)
March 18, 2024, 12:35pm
1
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!!
eldany.uy
(eldany.uy)
March 19, 2024, 10:26am
2
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
Ivan3z
(Ivan3z)
March 19, 2024, 11:00am
3
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
Ivan3z
(Ivan3z)
March 21, 2024, 7:38am
5
HI @eldany.uy
I think we fund the problem
Can you try to set “AllowBackgroundAudio” to true in the editor settings?
It is disabled by default - and I think that is why you are not hearing any sound (because the second PIE window has no user focus and thus is in the background)
[image]
Let me know if this fixes it
Unfortunately the solution seem to be bugged
Anyway i want thank you for your help!!
1 Like
system
(system)
Closed
April 20, 2024, 7:38am
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.