-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Sprite pivot (offset) #1616
Comments
This could be solved by using a hierarchy of entity:
Would that work for you? |
That doesn't solve the issue. Each sprite could have a different pivot, so as I said, you'd have to change the child's transform every time the sprite changes. That's what I'm doing currently as a workaround, but it's not a good solution. This feature is present in both Godot and Unity, and it should be in Bevy also. |
I attempted to implement this myself, but I didn't know how to apply the offset to the |
+1 Since we can generate sprites programatically it would be nice to specify a pivot. |
An easily configurable offset would also be really useful for pixel-art sprites. With the current centered behavior, odd-sized textures requires an offset of 0.5 to be aligned on screen pixels. |
# Objective - Fixes bevyengine#1616, fixes bevyengine#2225 - Let user specify an anchor for a sprite ## Solution - Add an enum for an anchor point for most common values, with a variant for a custom point - Defaults to Center to not change current behaviour Co-authored-by: François <[email protected]>
# Objective - Fixes bevyengine#1616, fixes bevyengine#2225 - Let user specify an anchor for a sprite ## Solution - Add an enum for an anchor point for most common values, with a variant for a custom point - Defaults to Center to not change current behaviour Co-authored-by: François <[email protected]>
What problem does this solve or what need does it fill?
It allows each sprite to be drawn at a different offset on the texture. For example, on a character sprite sheet, the pivot is often put at the character's feet, so that they always appear in the same place even if the sprites are different sizes or the pixels do not line up exactly.
What solution would you like?
There should be a
Vec2
on bothSprite
andTextureAtlasSprite
that determines the offset the sprite should be drawn at. It could be called pivot or offset.What alternative(s) have you considered?
The alternative is to offset the transform every time you change the sprite. It's tedious.
Additional context
Unity includes an enum that lets you to automatically put the pivot at certain parts of the sprite, like TopLeft or Center. I'm not sure if that should be on the sprite or should just be handled in the editor.
The text was updated successfully, but these errors were encountered: