diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index afa368fe9b..3ae3c0ea81 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -181,27 +181,30 @@ bool CollisionShape2D::_edit_is_selected_on_click(const Point2 &p_point, double String CollisionShape2D::get_configuration_warning() const { String warning = Node2D::get_configuration_warning(); + if (!Object::cast_to(get_parent())) { if (warning != String()) { warning += "\n\n"; } warning += TTR("CollisionShape2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape."); } + if (!shape.is_valid()) { if (warning != String()) { warning += "\n\n"; } warning += TTR("A shape must be provided for CollisionShape2D to function. Please create a shape resource for it!"); + } else { + Ref convex = shape; + Ref concave = shape; + if (convex.is_valid() || concave.is_valid()) { + if (warning != String()) { + warning += "\n\n"; + } + warning += TTR("Polygon-based shapes are not meant be used nor edited directly through the CollisionShape2D node. Please use the CollisionPolygon2D node instead."); + } } - Ref convex = shape; - Ref concave = shape; - if (convex.is_valid() || concave.is_valid()) { - if (warning != String()) { - warning += "\n\n"; - } - warning += TTR("Polygon-based shapes are not meant be used nor edited directly through the CollisionShape2D node. Please use the CollisionPolygon2D node instead."); - } return warning; } diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp index 4735910fc3..4167d4f691 100644 --- a/scene/3d/collision_shape.cpp +++ b/scene/3d/collision_shape.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "collision_shape.h" + #include "scene/resources/box_shape.h" #include "scene/resources/capsule_shape.h" #include "scene/resources/concave_polygon_shape.h" @@ -116,6 +117,7 @@ void CollisionShape::resource_changed(RES res) { String CollisionShape::get_configuration_warning() const { String warning = Spatial::get_configuration_warning(); + if (!Object::cast_to(get_parent())) { if (warning != String()) { warning += "\n\n"; @@ -128,23 +130,21 @@ String CollisionShape::get_configuration_warning() const { warning += "\n\n"; } warning += TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it."); - } - - if (shape->is_class("PlaneShape")) { - if (warning != String()) { - warning += "\n\n"; - } - warning += TTR("Plane shapes don't work well and will be removed in future versions. Please don't use them."); - } - - if (Object::cast_to(get_parent())) { - if (Object::cast_to(*shape)) { - if (Object::cast_to(get_parent())->get_mode() != RigidBody::MODE_STATIC) { - if (warning != String()) { - warning += "\n\n"; - } - warning += TTR("ConcavePolygonShape doesn't support RigidBody in another mode than static."); + } else { + if (shape->is_class("PlaneShape")) { + if (warning != String()) { + warning += "\n\n"; } + warning += TTR("Plane shapes don't work well and will be removed in future versions. Please don't use them."); + } + + if (Object::cast_to(get_parent()) && + Object::cast_to(*shape) && + Object::cast_to(get_parent())->get_mode() != RigidBody::MODE_STATIC) { + if (warning != String()) { + warning += "\n\n"; + } + warning += TTR("ConcavePolygonShape doesn't support RigidBody in another mode than static."); } }