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

Allow to manage node groups from the project settings #3789

Closed
hamoom opened this issue Jan 12, 2022 · 1 comment · Fixed by godotengine/godot#60965
Closed

Allow to manage node groups from the project settings #3789

hamoom opened this issue Jan 12, 2022 · 1 comment · Fixed by godotengine/godot#60965
Milestone

Comments

@hamoom
Copy link

hamoom commented Jan 12, 2022

Describe the project you are working on

I'm working on a 2D action RPG.
https://www.youtube.com/watch?v=0Y0-lZd_tD0&ab_channel=hamoom

Describe the problem or limitation you are having in your project

I have a large amount of groups in my game. It's very difficult to manage and keep track of them. They are assigned arbitrarily in the editor and there are probably groups assigned to certain scenes that are no longer in use. Also it's very error prone since I'm just using strings everywhere. I also have a singleton I use to reference the groups in code but I need to make sure my singleton matches the strings I'm assigning in the visual editor.

Some people have suggested I only assign groups programmatically but sometimes it's not convenient to do that when I want a particular instance of a scene to belong to a different group than it normally would.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

In order to have a single source of truth I would like groups to be used in this way.

  1. User must assign group names in project settings.
  2. In the scene you are only allowed to change group assignment from a pre-existing list.
  3. In the code editor the groups would be available to use in singleton form.

If it followed this format it would be one step to change group names or remove groups project-wide. It would also be impossible to make a spelling error or waste your time trying to remember if the group is named "enemy" or "enemies."

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

In the project settings we add a Group Names section right above Layer Names. This is the master list of groups that we can do normal CRUD operations on. The rest of the project updates accordingly based on this.

Screen Shot 2022-01-11 at 8 27 45 PM

This is how we'd reassign groups within a scene.
Screen Shot 2022-01-11 at 8 04 40 PM

# in code

var nodes_arr = get_tree().get_nodes_in_group(Groups.actors)

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't believe so because there's a lot of management involved in making sure your groups are correct. It could technically be done if you only use groups programmatically using a singleton but its much less convenient than being able to use the editor. My change would also remove the need for creating your own singleton that matches the groups you set in the visual editor.

Is there a reason why this should be core and not an add-on in the asset library?

Using groups is a central part of Godot and I believe this would make it much easier to use and less error prone for everybody.

@hamoom hamoom changed the title Improved Groups management. Groups management from project settings. Jan 12, 2022
@YuriSizov YuriSizov changed the title Groups management from project settings. Allow to manage groups from the project settings Jan 12, 2022
@YuriSizov YuriSizov changed the title Allow to manage groups from the project settings Allow to manage node groups from the project settings Jan 12, 2022
@me2beats
Copy link

see also
#907

@akien-mga akien-mga added this to the 4.2 milestone Aug 28, 2023
@AThousandShips AThousandShips modified the milestones: 4.2, 4.3 Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants