Skip to content

Relationship between game objects and components #53

Open

Description

@frostney

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.

Activity

  1. Polooo2 commented on Mar 9, 2014

    @Polooo2
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions