Clarification about CollisionObject2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RedPilled
  1. As per the docs, I understand that following hierarchy is followed:
     -ShapeOwner0 -> Shape2D0, Shape2d1......
     -ShapeOwner2 -> Shape2D0, Shape2d1......
     -ShapeOwner3 -> Shape2D0, Shape2d1......

Is this a correct visualization?

  1. Is there any other design motive to have shape owners as an intermediate between an Object and it’s collision shape, other than grouping collision shapes?

  2. Is CollisionPolygon2D also just a Editor-only helper node?

  3. Doc says create_shape_owner(Object) creates a new shape owner for the given object. However, while trying in GDScript, no matter which Object I provide, it creates an owner for the node calling this function. Is the Object parameter redundant?

:bust_in_silhouette: Reply From: RandomShaper

I’m porting my game from Godot 2.1 to 3.2 and I’ve also come across these doubts. I’ve been updating myself on how these things work (by checking the source code, mainly).

So here are my answers:

  1. Yes.
  2. The only reason I can think of is that a transform can be applied at once to many shapes, because it’s applied per owner and I guess that simplifies things like the inner workings of CollisionPolygon2D that applies its own transform to all the shapes it owns (those the polygon is decomposed in for use by the physics engine).
  3. In Godot 3.x, CollisionPolygon2D can work at runtime.
  4. How do you know? If you call shape_owner_get_owner() with the owner id returned by create_shape_owner() you should get back the Object you passed to it.