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

Option to un-center offset (origin) on collision shape rectangle #1170

Open
pajcek11 opened this issue Jul 7, 2020 · 6 comments
Open

Option to un-center offset (origin) on collision shape rectangle #1170

pajcek11 opened this issue Jul 7, 2020 · 6 comments

Comments

@pajcek11
Copy link

pajcek11 commented Jul 7, 2020

Describe the project you are working on:
Trying to have a node with a Sprite and Collision box/shape

Describe the problem or limitation you are having in your project:
The sprite's "origin" can be set to un-centered (top-left) as is the standard in many programs, but the collision shape allows for only the origin being "centered", messing everything up because now you can't just overlay the sprite and shape one over the other because they have two completely different origin points. Besides, what happens with pixel-perfection if the sprite has a size not divisible by 2? Where does then the center lie? That's why top-left is standard and superior.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Put a checkbox for "centered" in the collision shape, so people can un-check it just like they can on the sprite

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Collision shape rectangle should have some kind of centered property already, so just making the checkbox should be easy, if I am not wrong.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
It will most definitely be used often because it is essential and absolutely logical to have

Is there a reason why this should be core and not an add-on in the asset library?:
This should be an easy fix, and a logical addition. The current system is flawed for not having this.

@Calinou
Copy link
Member

Calinou commented Jul 8, 2020

Related to #452. I think modifying the editor tools to support this is a good enough solution.

That's why top-left is standard and superior.

Don't be so sure 🙂
Some pieces of software have moved from top-left origins to centered origins for various reasons. In many cases, it's more logical to extend from the center than from the top-left corner. There are certainly cases where you want the shape to extend from the top-left corner, but I think this can be done relatively easily already if you're changing the shape's size in a script. If you're changing the shape's size in the editor, then this is probably better addressed by #452.

Besides, what happens with pixel-perfection if the sprite has a size not divisible by 2? Where does then the center lie?

Godot allows floating-point coordinates in 2D (even if pixel snap is enabled), so I don't think this is much of an issue.

Collision shape rectangle should have some kind of centered property already, so just making the checkbox should be easy, if I am not wrong.

It's easy to implement, but it also means having to add and document yet another property (and therefore bloating the Inspector). Everything has a cost, even if it's not obvious at first.

@pajcek11
Copy link
Author

pajcek11 commented Jul 8, 2020

I really do hope that something is done about this, and that people will support it.
I wholeheartedly support issue 452.

Godot allows floating-point coordinates in 2D

I don't allow them though because they don't exist and make no sense.

It's easy to implement, but it also means having to add and document yet another property (and therefore bloating the Inspector). Everything has a cost, even if it's not obvious at first.

That's my kind of work-ethic ;P We'll never accomplish anything thinking like that.


Anyway, could you suggest some workaround for me in the meantime? It appears that the offset functionality isn't part of Node2D, so those properties don't even exist in the collision shapes? Could we inherit it somehow and then export the centered property? The goal is to be able to position collision shapes via code or editor, without using floating points, but real tangible pixel coordinates.

Tnx!

@KoBeWi
Copy link
Member

KoBeWi commented Jul 15, 2020

Anyway, could you suggest some workaround for me in the meantime?

I made a PR for #452 and I actually use it already in my custom Godot build (it's the same as 3.2.2 stable plus some bonus stuff), you could use it in the meantime: https://ufile.io/icpr90x8 (also you can test if #452 solves your problem)

@Shadowblitz16
Copy link

this needs to be added.
I need a way to align my tiles to a grid and tilemaps don't cut it
tilemaps don't support moving objects and collision logic

@Georges-SR
Copy link

Georges-SR commented Sep 25, 2023

Any news on this convenient feature ?
I wholeheartedly support it, as many others I'm sure.

@Calinou
Copy link
Member

Calinou commented Sep 25, 2023

Any news on this convenient feature ? I wholeheartedly support it, as many others I'm sure.

To my knowledge, nobody is currently working on implementing this. This feature doesn't seem to have a lot of community support, and would come with a fair bit of added complexity on its own. Also, we can have editor helpers to resize shapes from their top-left corner (like we have in 3D already).

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

5 participants