Skip to content
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

Relationship between game objects and components #53

Open
frostney opened this issue Feb 22, 2014 · 1 comment
Open

Relationship between game objects and components #53

frostney opened this issue Feb 22, 2014 · 1 comment

Comments

@frostney
Copy link
Member

Currently, there are a few software design-related problems in Lyria:

  • Prefabs are just a scene (in fact, they do provide too much overhead currently as prefabs do have some events and methods that don't make sense in this context)
  • Game objects and their relationship to other objects is non-existent
  • Game objects have no purpose currently - it's easier to either to a prefab or write all the needed stuff in the scene itself
  • Objects that should have GameObjects as its base (lyria/sprite) only exist as a shell

What I propose is the following structure:

  • GameObjects have markup and code like scenes & prefabs (definition of an object)
  • GameObjects can attach components to them
  • Components only have code and no markup (logic for an object)
  • Prefabs can attach GameObjects and Components to themselves
  • Scenes can attach Prefabs and GameObjects to themselves
  • GameObjects can bind to an object and load its default values from it
  • Sprites would logically be a GameObject with a or multiple components attached to it
  • It should be easy to interact with a GameObject from a container object (Prefabs, Scenes)

In my opinion, this helps to separate each aspect of Lyria and gives it a specific purpose. (And it resembles the entity-component pattern to a high degree.) Let's take a player as an example: Instead of it being a markup and code in every scene/prefab we need it to be, it would a GameObject and can be inserted in any number of scenes and prefabs reducing maintainability.

@Polooo2 I would really appreciate your feedback on this.

@Polooo2
Copy link
Contributor

Polooo2 commented Mar 9, 2014

Sry for late answer.

I have the same opinion. In my experience you often need a prefab by several scenes and some "components" from several prefabs. Currently I often created small prefabs (e.g. slider elements or some ui element with minimal logic) to be used in "bigger" prefabs.

I would only change the structure a little bit:

  • GameObjects a only a shell
  • components are logic only (code)
  • some other elements (templates?) are markup only
  • a GameObject should consist of at least either one component or one template(?) or both and can combine some markup with some logic

Furthermore I think it would be nice if one component could be used by several GameObjects (same for template). It would create the possibility to have several GameObjects with similar functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants