How to change center of AtlasTexture region?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BustedCable

So, I want to use a spritesheet for my main character’s animation in a 2D game. For the purposes of this question, I’m using this Link spritesheet as an example:

However, if I were to select the regions, the slash animation wouldn’t be aligned correctly with the character’s original position and hit-box. How would I go about fixing this issue?

:bust_in_silhouette: Reply From: The_Black_Chess_King

As you can see, the char is not on center, you need to offset him to match the center, you can try:

1- EDITING YOUR IMAGE SPRITE: Increasing the spritesheet size and size for each sprite, so to fit the weapon animations while keeping your character in the center, so you would have to edit the image and correct it. Downside is you will end up with a huge empty space, but it would not need to change nothing else, besides the sprite resource on your game. #Normally if you create your own sprites, you already center the sprites as to not have to worry about offseting later.

2- USING OFFSETS FROM A AUTOLOAD: Creating a data bank of offsets linked to animations references, like for example, a global dictionary, which will contain all the animations offsets for each animation, the benefit of this is that you will have precise control over the offset and will not need to edit the base sprite image, but it gives a lot of work, as you probabily will need to create a in-game tool to check where is the center of the char, or try to force brute guess the right offsets. Obviously is more advance but will work.

ANIMATIONS = {
    "SLASH_DOWN":{
         "SPRITE_OFFSET": Vector2(0,0),}
    "SLASH_UP" :{
        "SPRITE_OFFSET": Vector2(0,0),}
}

3- SEPARATING THE SWORD FROM THE CHAR: You could in a maybe more simple way, re-edit the sprites to separate the sword and the character, and later you could animate using the animation editor, that is the easiest way, It would also reduce your animations size, because you could use multiple weapons with the same animations, and you would only need a few animations with the sword, down, up, right left, maybe some swings.This is a modular design approach which you need to think if it’s worth it, you would have to pay attention to the sword not clipping into the character as well.

There could be also more options, see what works better for you, see what other people did.