How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 20 May 2021 11:13
by Stellar

The design of my character is off-center... they carry a weapon. Because of this, when I flip them from left to right, it looks like the character jumps from side to side. How do I adjust the centerline so they flip based on the center of their body instead of the center of the sprite? Thanks!


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 20 May 2021 22:07
by Elringus

Use layered implementation (you can freely position layers inside the prefab there) or add slack transparent space to the texture when using sprite implementation. Starting with v1.16 diced sprite implementation also allows specifying custom pivots.


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 24 May 2021 10:51
by Stellar

Hi Elringus,
Thanks for the reply. In my case, the character is a "SpriteCharacter", can you explain in more detail how to "add slack transparency space to the texture"? Is there a setting in Unity/Naninovel to do this, or do you mean adding transparent space to my png file in an image editor before bringing it into Unity?
Thx!


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 24 May 2021 11:48
by idaot

By slack transparency he probably meant to add extra transparent pixels so the body of the characters is centered on the image. I don't think it's possible to do within Unity.

If space is a concern then I recommend registering your copy and downloading the 1.16 pre-release in our Discord channel which now has an option to set a custom pivot via Diced Sprite Atlases: https://naninovel.com/support/#naninovel-support


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 02 Jun 2021 11:08
by Stellar

Hi idaot,

Thanks for the help. I went with the Diced Sprite option. I got the dicing working, but changing the pivot doesnt seem to have any effect. For the record, I made sure to "Rebuild Atlas" after I adjusted the pivot.
Is there a setting somewhere else I need to adjust?


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 02 Jun 2021 11:13
by Elringus

Make sure you're using latest sprite dicing version and Keep Original is enabled in atlas settings. You can find example of custom diced sprite pivots controlled by sprites of the original textures in the sprite dicing project.


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 02 Jun 2021 12:13
by Stellar

Thanks. "Keep Original" doesn't seem to help me center my character when I flip it with the "look" command. Where can I find the sprite dicing project?

I made a visual representation of the problem I'm trying to solve. Thanks for the help!...

Image


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 02 Jun 2021 15:10
by Elringus

Don't forget to specify the custom pivots for the source textures (sprites) with sprite editor: https://docs.unity3d.com/Manual/SpriteEditor.html


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 02 Jun 2021 16:27
by Stellar

Thanks for the tip.

I followed this tutorial: https://www.youtube.com/watch?v=6PdOAOsnhio

Plus I set the custom pivots for all source sprites in the Sprite Editor like you suggested, and rebuilt the Atlas. But still, when I flip the image using "look", it acts like I didn't make any pivot adjustment at all.

Not sure what I'm doing wrong.


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 02 Jun 2021 17:59
by Elringus

My bad, I misunderstood your use case. Diced implementation will render the source sprites to a texture, which has its own pivot that can be set in char config. It's not possible to specify custom pivot per appearance.

Image


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 03 Jun 2021 06:49
by Stellar

Hi Elringus,

Thanks for the help. That pivots the character in relation to the screen, but that's not really addressing my issue.

My issue is... when I use the look command to flip my character, the flipped version doesn't line up how I need it to with the default (baked look direction) version. I need to offset the flipped version of the character only.

Could you revisit my visual above to see the problem? Thanks.


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 03 Jun 2021 07:29
by Stellar

If you check this tutorial, first example, he addresses the same problem I'm having (he's showing it in Unity without Naninovel). I tried following his steps and it still didn't work. Pivot moves the default character around on the screen, but it doesn't offset the flip. https://www.youtube.com/watch?v=yVSa1wurt8s

Also I noticed I don't see a "Sprite Renderer" panel where I can check the Flip. Is there a way to turn it on? Thx.


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 03 Jun 2021 08:06
by Elringus

The char pivot controls pivot relative to sprite, not the screen. As I've mentioned before, most implementations render source representation of the actor to a texture. Look command basically flips that render texture and pivot won't affect the process (sorry for the misleading info on that in my initial answer). I'd still suggest trying a layered implementation or centering your characters on the source textures. You can flip them manually (eg, flip horizontally with PS) to estimate how the look command will work in the engine.


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 03 Jun 2021 09:01
by Stellar

Sorry for confusion on this.

You said "The char pivot controls pivot relative to sprite, not the screen."

If I understand correctly, doesn't that mean I should be able to place the X-axis pivot point right down the center of the character's body and when I flip the character using the look command, it should flip the image along that line? That's what I'm trying to do but it doesn't seem to work.

Image


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 03 Jun 2021 09:53
by Elringus

Pivot doesn't affect how the look direction is applied in any way, as it just flips the texture. Try performing flip horizontally in photoshop for an example.


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 03 Jun 2021 12:41
by Stellar

Understood. I was able to get the flip to line up correctly by creating a layered character like you suggested. Thank you!


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 03 Jun 2021 14:35
by Stellar

Hey Elringus,

I noticed when I use the Layered Character method, when I transition from one sprite to the other, the first sprite flashes to black and fades away. For example:

@char Test.Outfit1>Annoyed1
1
@char Tester.Outfit1>Annoyed2 <As soon as this switches to "Annoyed2", "Annoyed1" flashes to black and fades away.
2

When I use a regular Sprite Character, the transition is transparent and looks much smoother. Is there a way to turn off that black thing? Thanks!


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 03 Jun 2021 16:07
by Elringus

Please PM me on Discord with a repro project (https://naninovel.com/support/#reproduction-project).


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 04 Jun 2021 13:00
by Stellar

PM sent!


Re: How do I adjust the centerline of a Character when I flip them from left to right?

Posted: 07 Jun 2021 13:45
by Stellar

To help anyone reading - Elringus was able to find and fix the error with the transition looking black instead of transparent. I imagine that will be fixed in an upcoming release.