diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp index b33746451ab..5231b2ea1ea 100644 --- a/scene/3d/visibility_notifier.cpp +++ b/scene/3d/visibility_notifier.cpp @@ -85,15 +85,18 @@ void VisibilityNotifier::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { - get_world()->_register_notifier(this, get_global_transform().xform(aabb)); + world = get_world(); + ERR_FAIL_COND(!world.is_valid()); + world->_register_notifier(this, get_global_transform().xform(aabb)); } break; case NOTIFICATION_TRANSFORM_CHANGED: { - get_world()->_update_notifier(this, get_global_transform().xform(aabb)); + world->_update_notifier(this, get_global_transform().xform(aabb)); } break; case NOTIFICATION_EXIT_WORLD: { - get_world()->_remove_notifier(this); + ERR_FAIL_COND(!world.is_valid()); + world->_remove_notifier(this); } break; } } diff --git a/scene/3d/visibility_notifier.h b/scene/3d/visibility_notifier.h index 47418bbbb48..170498e4094 100644 --- a/scene/3d/visibility_notifier.h +++ b/scene/3d/visibility_notifier.h @@ -33,11 +33,13 @@ #include "scene/3d/spatial.h" +class World; class Camera; class VisibilityNotifier : public Spatial { GDCLASS(VisibilityNotifier, Spatial); + Ref world; Set cameras; AABB aabb;