diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index cbd3c244d95..4fc0fe02687 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -196,6 +196,7 @@ Ref AudioStreamPlayer2D::get_stream() const { } void AudioStreamPlayer2D::set_volume_db(float p_volume) { + ERR_FAIL_COND_MSG(Math::is_nan(p_volume), "Volume can't be set to NaN."); internal->volume_db = p_volume; } diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index f1f9a04ea05..0cef56dbf24 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -496,6 +496,7 @@ Ref AudioStreamPlayer3D::get_stream() const { } void AudioStreamPlayer3D::set_volume_db(float p_volume) { + ERR_FAIL_COND_MSG(Math::is_nan(p_volume), "Volume can't be set to NaN."); internal->volume_db = p_volume; } diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index dadcfab69f4..0c2bd64e845 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -59,6 +59,7 @@ Ref AudioStreamPlayer::get_stream() const { } void AudioStreamPlayer::set_volume_db(float p_volume) { + ERR_FAIL_COND_MSG(Math::is_nan(p_volume), "Volume can't be set to NaN."); internal->volume_db = p_volume; Vector volume_vector = _get_volume_vector();