diff options
Diffstat (limited to 'scene/2d/collision_object_2d.cpp')
-rw-r--r-- | scene/2d/collision_object_2d.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 7ade74e8a6..738f7ddf59 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -58,6 +58,14 @@ void CollisionObject2D::_notification(int p_what) { //get space } + case NOTIFICATION_ENTER_CANVAS: { + + if (area) + Physics2DServer::get_singleton()->area_attach_canvas_instance_id(rid, get_canvas_layer_instance_id()); + else + Physics2DServer::get_singleton()->body_attach_canvas_instance_id(rid, get_canvas_layer_instance_id()); + } + case NOTIFICATION_VISIBILITY_CHANGED: { _update_pickable(); @@ -86,6 +94,14 @@ void CollisionObject2D::_notification(int p_what) { Physics2DServer::get_singleton()->body_set_space(rid, RID()); } break; + + case NOTIFICATION_EXIT_CANVAS: { + + if (area) + Physics2DServer::get_singleton()->area_attach_canvas_instance_id(rid, 0); + else + Physics2DServer::get_singleton()->body_attach_canvas_instance_id(rid, 0); + } } } |