godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.13k stars 93 forks source link

Autoadjust CapsuleShape2D when upgrading to 4.x from 3.x. #7420

Open SaffronStreams opened 1 year ago

SaffronStreams commented 1 year ago

Describe the project you are working on

I've imported my 3.5.2 project into Godot 4.1. It's a 2D project.

Describe the problem or limitation you are having in your project

One of the things I've noticed is that a lot of my collisions seem to have shrunk. Looking at CapsuleShape2D, I notice two parameters: radius and height. Before these seemed to have been applied separately, 15 radius and 100 height gave a total height of 130. In 4.1 the meaning seems to have changed and height is now total height (instead of something like "extra" height). The importer leaves the values as is, which leads to shrinkage of the shape.

F2XsvRwWAAIU6sD F2Xsx_qXEAIeXPG

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

Autoadjust the height parameter to keep the original intended size of the capsule.

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

The meaning of height has been changed, but the solution to keep the old actual shapes seems easy: add 2 radius to each height of CapsuleShape2D when importing from 3.x.

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

Work around with going through all capsuleshapes in project. Depending on the project these can be many or few.

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

As there are still quite a few people in 3.X waiting to jump over to Godot 4.x, removing friction with a (seemingly?) easy fix could help more people transition to the future of Godot.

SaffronStreams commented 1 year ago

For RectangleShape2D, the x and y have changed from extents to size, and so need to be double to get the same shape. This is seemingly something that could also be autocorrected when importing.

Calinou commented 1 year ago

If the properties haven't been renamed since 3.x, it's unfortunately not possible to do this. The property needs to have a different name in 3.x, so it can use a magic getter that will change the value that is saved in the new property name.

The project converter itself is pretty basic, and only handles renames, not property conversions. As a result, the magic getter is the only way to automatically convert a value from one unit system to another.

KoBeWi commented 1 year ago

I have a converter that handles this and some other more advanced cases: https://github.com/KoBeWi/Another-Godot-4-Converter You can run it on a specific scene.

SaffronStreams commented 1 year ago

The project converter itself is pretty basic, and only handles renames, not property conversions. As a result, the magic getter is the only way to automatically convert a value from one unit system to another.

The suggestion would be to modify this project converter, possibly combined with other things that KoBeWi's tool does, but perhaps there is a reason why the converter can not be modified that I don't realize?