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
Made pivot the new location of entities spawned in the world #143
Conversation
The size of the visual area for an entity should only be an indicator to the user about how big it will seem, changing the size should not change where the entity spawned. This is how it works in most other engines I've seen and I believe it's better to have a defined point which can be seen in the editor to represent the translation of the entity, rather than arbitrarily moving them half way up.
Thanks for the contribution! I'm not sure about this. I think there's a lot of situations where you would expect the current behavior. My current project even depends on the current functionality. I would be down to accept it as an option though! That will require creating a new field on the |
Maybe the current behavior could be changed to use the |
I feel like something should change about the pivot. When using Point values, I find it very difficult to use. Btw, in the |
Thanks for commenting, it's always good to know when a suggestion would help others.
This is true for the default
I'm not sure this is true, I looked over it again and it looks "correct", unless I'm misunderstanding your suggestion. |
The other |
Ah, I think I see what you're saying. There are other utils functions that expect ldtk pixel coords instead of grid coords, and they also use |
Wouldn't you just use a pivot in the center if you needed this behavior? It seems a lot more straight forward than adding more parameters or coupling it to the rendering system. |
For many games, yes. But for tile based games, in order to put an entity in the center of a tile, the "center" pivot option won't work. In that case, placing entities on the grid wouldn't put the entity in the center, it would put it on some intersection of the grid. I suppose you could set an offset for the entity layer so it's grid bisects the grids of other layers, but that's not an obvious solution to me.. Anyway, Ive been convinced that this behavior needs to change. I would like to...
I think these should be separate PRs. We could close this PR or change it so it accomplishes task 2 without doing anchor stuff. Thoughts? Do you think this solution will work for you? Again, thanks so much all for bringing this to my attention, I had no idea this was problem for users before this PR. |
I don't think it should use the anchor point, since it would be particularly finicky with precise anchors, though I can imagine that being a convenient default to have. How about we add an enum like so #[derive(Component)]
pub enum TransformImportSetting {
Pivot,
Center,
Anchor,
} Where pivot is the behavior I want, Center is the behavior it currently has, and anchor is the behavior you're suggesting. This would solve both of your desired changes, no? We could have a function for the app which can register a default behavior for all your imports and adding this component to an LdtkIntGrid bundle could would override the default behavior. I'm pretty new to both bevy and this library (I can't even get IntGridCell queries to work right haha) but hopefully this is a suitable solution. Also I'm glad I could help! Thanks for the awesome library! |
Could you give an example of where this would be an issue?
Hmm, The naming is tricky here. I think you mean
A more specific name would probably be better - maybe I don't think we need to make it a component, a field on the |
Merry Christmas! Sorry for the late reply I was away visiting family. I didn't know about the I'd be happy to make it just a setting, and I'd imagine since it's taken as long as it has to raise this issue and the fact that I'd be happy only using the pivot as the translation point I'd imagine that no one needs that level of control. As long as there's a way to get the visual rectangle bounds when hooking into entity creation.
What you said here is accurate
I'm not exactly sure what you mean by the latter, but regardless we could just be more verbose, I mean hell you're only using it once. And I'm thinking we could either use the Anchor component, or use a custom anchor because that would probably be easy to implement. How about pub enum LdtkEntityTranslation {
PivotAsTranslation,
VisualCenter,
AnchorOverVisual,
Custom(Anchor),
} Just so we can have entities spawn in the center and change how the sprites load in if we need that level of granularity, though I'd be happy to omit the |
Merry belated Christmas! Obviously I took a bit of a break too. So, no worries - we're all volunteers here. I'm not exactly against the possibility of a Also, naming things is hard... Now that I think about it, not all of these options are totally related to the literal "translation". After all, pub enum VisualPlacementStrategy {
Anchor,
Translate,
}
pub enum LdtkEntityPlacement {
MatchVisual(VisualPlacementStrategy),
PlainPivotPoint,
} Or, if we don't have a pub enum LdtkEntityAnchor {
FromPivot,
None,
} I'm trying to make a distinction between "pivot" and "pivot point", where pivot refers to the pivot field of an ldtk entity that defines where the entity's visual is in relation to its pivot point, and pivot point refers to the actual pixel coordinates of the entity in a level. Thoughts? |
I like that there's you're trying to make a distinction here, but I doubt any explanation of this would reach the users, and I think we can make it clearer. I agree that adding all these options is probably more work than it's worth (and I can't really think of any examples, it just feels like it's coupling things that feel like they shouldn't be coupled), and quite frankly the only 2 options we collectively care about are using the pivot as a translation point and using the visual area's center as the translation point. Without the other options, we don't have to worry about how the sprite will now render and the name "translation" makes a lot more sense. pub enum LdtkEntityTranslation {
VisualCenter,
Pivot,
} I'd be fine without the extended functionality, and I think this is very clear / easy to use. But yeah, it's a small part of the library and it feels like we're thinking too hard about what we name them, as long as there's something in the docs in an easy to find location pointing to this api then I think that works just fine. |
Yeah we're definitely getting a little too hung up on the naming. I think we should just focus on incremental improvements. This I think that would be a good way to wrap up this PR - add that simple 2-variant |
The size of the visual area for an entity should only be an indicator to the user about how big it will seem, changing the size should not change where the entity spawned.
This change is how it works in most other engines I've seen deal with it, and I believe it's better to have a defined point which can be seen in the editor to represent the translation of the entity, rather than arbitrarily moving them half way up their visual area.