-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instancing of a scene does not instance a new ConcavePolygonShape in a collision shape #40887
Comments
The
Set |
The problem is that the ConvexPolygonShape is not like a normal resource. It is used as a container that always starts out as empty. The shape only gets created by feeding it a list of triangles. https://docs.godotengine.org/en/stable/classes/class_concavepolygonshape.html When you instance a scene, all the container nodes are cloned, so when I add new elements to a subnode in one instance those elements do not appear in the subnode of another instance. The same principle should apply to this node. With the current implementation, anyone who does not write |
Yes, that works perfectly. Can that flag definitely be set to true by default? It's proven to be difficult for both of us to find, and I can't think of a use-case for to be set to false for these procedurally generated objects. |
Shapes are shared by default for performance reasons. |
Godot version:
3.2.2.stable
OS/device including version:
ubuntu 18.04
Issue description:
If you use a scene to procedurally generate static bodies using the SurfaceTool and the
shape.set_faces()
function, then it comes as a surprise to learn that each time you instance a new one it over-writes the triangles that are assigned to the concave collision shapeThis is a very difficult bug to discover, particularly when your procedural shapes are reasonably similar and there's something about the physics that doesn't look right.
The work-around is easy. Put
$CollisionShape.shape = ConcavePolygonShape.new()
in the_ready()
function of the static body. The current behavior of not applying the deep-copy to this Collision object when the scene is instanced is not functionally useful. This might be a special case, however. Maybe the other pre-configured shapes (box, cylinder) are sufficiently constrained that they can be shared, because it is not their purpose to have procedural geometry inserted into them.Animated gif shows two procedurally generated ramp static bodies with cubes rolling down them, where the collision shape of the steeper ramp has overwritten the collision shape of the shallow ramp.
Steps to reproduce:
See below.
Minimal reproduction project:
collisionclonebug.zip
The text was updated successfully, but these errors were encountered: