Character offset when scaling is not 100 %

Started by rongel, Fri 07/05/2021 08:18:32

Previous topic - Next topic

rongel

I have a small problem with couple of my animations. 

When my character's scaling is not 100 %, and I want to animate him using a loop that is bigger than his defaul sprite, there will be a slight, but an annoying scaling offset. It can be seen more clearly if the animation is only for the hand, or head, and rest of the body stays still. The effect is that the character jumps about 1/2 pixels left or right.

Is there anyway to avoid this? In certain cases, the animation loop has to be bigger than the character sprite, and if the character is scaled up or down, the problem will show up. I found out that I can fix it a little bit by moving my sprite to the other end of the frame when drawing it, so that the action fits to the default sprite size. Then I used LockViewOffset to center it again in the game. But even then, I can notice a slight jolt or a jump in the sprite.

Is there anyway to make make the transition absolutely flawless if the scaling is not 100% and there's a difference in the loop size?

I tried to search older topics for this, but couldn't find them. Any help is appreciated!
Dreams in the Witch House on Steam & GOG

Khris

You can make sure that the width in pixels of all character sprites is either even or odd. If the tiny offset persists, you have to make all character sprites the same width.

rongel

Quote from: Khris on Fri 07/05/2021 09:01:49
You can make sure that the width in pixels of all character sprites is either even or odd. If the tiny offset persists, you have to make all character sprites the same width.

Thanks for the input! Yes, I've used even pixel sizes in my sprites width. In my example, my character has an object, that he can look at any time. The normal character width is 50, but this look animation has a width of 52. All of the loops have the character aligned in the middle of the frame. Depending on the characters scaling, it will show a annoying jump when the animation plays. Sometimes it's bigger, sometimes smaller (character's scaling value affects it).

It might be that it doesn't bother so much other people, but I find it quite annoying. So if there's no magic tricks, I need to think about making the frame of the character a bit wider.
Dreams in the Witch House on Steam & GOG

Khris

Scaling a 50 pixel wide sprite down to 80% and doing the same with a 52 pixel wide sprite will give "massively" different results. I'm not surprised it's noticeable. You can only get away with that in highres games.

Crimson Wizard

#4
Quote from: rongel on Fri 07/05/2021 08:18:32Then I used LockViewOffset to center it again in the game. But even then, I can notice a slight jolt or a jump in the sprite.

There's also Character.LockViewAligned, idk if may work better?
Quote
The main purpose of this command is that it can align the new frame to the previous one. This is particularly useful if you want to go from the character's normal walking view to a specific animation - since characters have the central point as their 'axis', if you have a wider animation then it can be difficult to stop yourself getting a jumping effect when the animation starts.

rongel

Quote from: Crimson Wizard on Fri 07/05/2021 12:09:54
There's also Character.LockViewAligned, idk if may work better?

Thanks for the tip! I just tested that, but it the results seem the same. And my all of my animations are aligned at the center, so the default LockView is basically what I want. I feel that these commands are useful if the scaling is at 100 %, and the sprite's size is changed and/or position in the frame is different. This is from the manual:

QuoteeAlignCentre Leaves the frames centered in the middle.
This is the default and using this is equivalent to just calling LockView.

When the action is blocking, and I know the scaling of the character, I can play around with the width of the animation spite. Like if I change the width from 52 to 54 it may work better when the character is scaled to certain value. Problem is that the player can look at the item in several different scaling situations, and some of them scale nicely, some cause that irritating jump.
Dreams in the Witch House on Steam & GOG

Crimson Wizard

#6
I don't know if this is related to the above problem, but recently I was doing some research in the engine code, and found out that the frame offset is not scaled with character... which is pretty weird imo.

That is, for example, if you call LockViewOffset or LockViewAligned, the offset will be calculated using original sprite size, but when character is scaled the sprite's size changes, yet locked offset stays the same...

This sounds too strange to be true, so it would be good to test this out more carefully.
I mean, that could have certain sense with LockViewOffset and manual scaling, but not with LockViewAligned.

Snarky

Didn't we also learn that the same is true of the Z-offset? Which basically means that you can't use it in games with scaling characters.

Crimson Wizard

#8
Quote from: Snarky on Sat 15/05/2021 08:21:53
Didn't we also learn that the same is true of the Z-offset? Which basically means that you can't use it in games with scaling characters.

You sort of can, if you will change it in realtime as z = (NORMAL_Z * Character.Scaling / 100).

But in case of view offsets it's obvious they should be scaling, in case of "z" it's not clear whether its purpose means it should be scaling.

Snarky

How do you figure? The original use case was to place the baseline at characters' feet (rather than the bottom of their shadow or simply sprite padding), and I cannot think of any other case you would use it for where you wouldn't want it to scale.

Basically, when you're scaling the X and Y axes, why wouldn't you scale the Z axis?

Crimson Wizard

I was thinking more about manual scaling, where you might as well want to have a custom z (y offset) unrelated to the sprite scaling. But then maybe it's the general issue with not being able to distinguish sprite's scale and scale of all object's aspects in whole.

SMF spam blocked by CleanTalk