godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.11k stars 69 forks source link

new VisualCollider2D for better non tileable 2D world creation #10124

Open Jesusemora opened 2 months ago

Jesusemora commented 2 months ago

Describe the project you are working on

not a 2D game, but I helped with one recently

Describe the problem or limitation you are having in your project

I usually help people who are just starting with Godot. The other day I was watching boxbox stream as they were making their game. I usually work with 3D so this isn't something that directly affect me, but I noticed that the workflow for creating non-tileable 2D worlds is cumbersome and leads to bad performance. Ideally, there should be as few StaticBody2D nodes as possible, containing many colliders, (is this correct?). This however leads to a disconnect between the physical and visual aspects, and not many people want to bother with this. The workflow taken by most then (when not dealing with tilemaps) is to create parts of the scenery, add them to the world and scale them. this leads to scaled colliders and trouble selecting different parts, and it's limited. This isn't a problem in 3D where colliders can be created automatically from meshes, or imported from blender, but it is a problem in 2D.

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

we can very easily introduce a new node inherited from CollisionShape2D. I made one such in gdscript: Captura desde 2024-07-05 23-22-27

this VisualCollider2D node could be the base for other visual collider nodes dealing with shapes other than square, and a variant could use sprites.

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

1 - we add VisualCollider2D nodes as children of one or more StaticBody2D or even other nodes, it handles both collision and the visual aspect, combining them into a single node. 2 - this node can be easily edited, changing the collider shape results in changes in the visual part, allowing artists/level designers to work with a solution with good performance that can be adapted to their needs. Captura desde 2024-07-05 23-22-16

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

yes, but this has more to do with making godot more accessible and easy to use. this solution could be the alternative to tilemaps, for 2D worlds that require angled shapes and scaled objects, without the use of scale.

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

it will help new users create better 2D levels, resulting in an improvement in performance for their games. Sprite2D will not be obsolete, as it creates shapes without collision. This combines collision and the visual side into a single node, allowing users to rotate and resize shapes without fear of breaking it.

AThousandShips commented 2 months ago

I think this is exactly suited for an add-on or extension and not in core

Generally Godot is designed with the idea that each node does one task, and you build functionality by combining them. In my experience trying to make multi-purpose nodes tends to almost always result in a node that does all the different things it tries to do badly

Nodes like this will be harder to maintain as they won't ever be as capable as a complex hierarchy, so they'll get far less use and therefore are far harder to maintain, simply because they get less use, yet they still have to be maintained, adding tech debt.

Having some form of 2D equivalent of CSG though would be interesting, for fast prototyping, but this proposal doesn't look like it would provide that

Calinou commented 2 months ago

Having some form of 2D equivalent of CSG though would be interesting, for fast prototyping, but this proposal doesn't look like it would provide that