0 votes

HI Godot Heroes

Can you give me some advice on the best way to implement a design...?

I am just getting started with Godot, and I am loving it! I am so impressed with how quickly you can put together complex capabilities.

I am working on a project where the player builds a vehicle made of Components. For example, Engine, Storage, Wing, Steering etc.

I plan to use a Scene to represent each component. The scene will contain regular Godot nodes such as a RigidBody and Collision shape. The base node of the scene will have a generic Component script which handles common features of all Components (naming logic, mass & center of gravity, etc etc). Then I plan to create a library of scenes to represent different types of component, eg Engine, Wing, Storage Bay, etc. In game, the user should be able to connect these together to build a vehicle.

When I define these additional scenes, there will be various capabilities that components need to have - for example "connect to another component" or "contain other components" or "contain fuel". These capabilities will need to be reusable, for example a subset of components can connect to other components, and a different subset of components can contain fuel, or provide drag etc.

To build this in Godot, I was thinking of creating a series of Objects, one for each capability such as Connector, Fuel Container, Drag Provider, Lift Provider etc and then use these Objects as children of each Scene/Component to define what the Component can do.

As an example
Scene / Component = Nose Cone
+ Object: Logic for Mass & Center of Gravity
+ Object: Logic for External Drag
+ Object: Logic to Connect to one other component (radial connection at the open end of the cone)
+ Object: Logic to contain other Components

Scene / Component = Wing
+ Object: Logic for Mass & Center of Gravity
+ Object: Logic for External Drag / Lift
+ Object: Logic to Connect to one other component (lateral connection)
+ Object: Logic to contain Fuel

Scene / Component = Fuselage
+ Object: Logic for Mass & Center of Gravity
+ Object: Logic for External Drag
+ Object: Logic to Connect to two other components (and the front and back of the fuselage) and optionally other components (eg lateral connections for wings)
+ Object: Logic to contain other Components

Scene / Component = Engine
+ Object: Logic for Mass & Center of Gravity
+ Object: Logic to sit inside a component which is a container
+ Object: Logic for Thrust calculations

Does that look like a sensible design for Godot?
Does anybody have any other ideas for how this should be implemented?

Thanks very much for your help

in Engine by (490 points)

I don't know how much I can help you with your project. Have you looked at the Best Practices for the engine, especially the "Applying object-oriented principles in Godot" section?

Thanks for taking the time to read my loooong question.

Yes, I have read those pages carefully and watched every tutorial I can find on this topic. I am new to object-oriented design - I think my design follows the recommended pattern, however I was looking for some feedback to see if I missed something.

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.