Question about Scene Inheritance and Collision Shapes

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By scrubswithnosleeves

Hey All,

I am making a game and trying to inherit from a base “enemy” scene. (this is my first time using inheritance in godot).

Everything works fine except that changes to the inherited scene collision shapes are affecting the parent. As the different enemies will have different sizes and thus collisiionshapes/hitboxes, this is an issue.

Any ideas on how to resolve this? My only idea right now is to do so through export Vector2()'s and then set the collision shape size in the ready() function.

:bust_in_silhouette: Reply From: Ertain

If inheritance is going to be an issue, maybe rethink using it for the “enemy” base class? Instead of having a single collision shape, why not have base functions to change the collision shape for each enemy? The base “enemy” class should have properties, functions, and other stuff which should accommodate each enemy. So functions which can change each enemy collision shape as necessary is probably a better idea.

1 Like
:bust_in_silhouette: Reply From: scrubswithnosleeves

Ended up answering my own question:

For each CollisionShape in the inherited scene, go to the inspector and click on the “Object properties” (lil screwdriver and wrench icon in the top right of the inspector). Then click on “make subresources unique”. Then you can change the collision shape’s shape in the editor without affecting the parent.

1 Like