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

Throw an exception when shape extents are set to negative values #3136

Closed
carllacan opened this issue Aug 14, 2021 · 3 comments
Closed

Throw an exception when shape extents are set to negative values #3136

carllacan opened this issue Aug 14, 2021 · 3 comments
Milestone

Comments

@carllacan
Copy link

Describe the project you are working on

2D platformer.

Describe the problem or limitation you are having in your project

I was trying to change the extents of a shape with a script. By mistake I was setting them to negative values, and this was preventing collisions from being detected, which was confusing because the collision shape was still visible both in the editor and in-game, and with the correct size.

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

Throw an exception, or at the very least a warning, when any of the extents of a shape are set to negative values, to aid debugging.

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

The game would crash and an error would inform the developer of their mistake. Alternatively the game would keep on working and they would get a warning in the editor.

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

It can be worked around by not making a mistake and setting the extents to negative values, but if it happens it can be very confusing.

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

There is no reason (that I can see) that a developer would ever want the extents to be negative, and allowing them leads to bugs.

@AaronRecord
Copy link

Maybe just limit the size to >=0?

@Calinou
Copy link
Member

Calinou commented Aug 14, 2021

See godotengine/godot#37376, but it doesn't apply to collision shape extents. Nonetheless, I can't see any valid reason to use negative extents in a collision shape, so it should be possible to print an error message here without any risk of false positives.

@akien-mga
Copy link
Member

Fixed by godotengine/godot#58343.

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

4 participants