This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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.

in Engine by (616 points)

2 Answers

+2 votes
Best answer

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.

by (616 points)
0 votes

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.

by (3,164 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.