#Problem with my character flip.

1 messages · Page 1 of 1 (latest)

fathom vortex
#

Make sure the origin of the Sprite2D node is at the center of the sprite.

steep token
#

It is

#

It's the little cross above the center of the collisionshape

fathom vortex
#

Are you sure that is from the sprite?
When you click the node, does it turn orange?

steep token
#

Yes

fading bane
#

This will only happen if the node being "flipped" doesn't have its origin centered where you would expect. Double check your node tree and you'll find one not centered.

steep token
#

Welp the origin is centered

#

This is how it looks like

fathom vortex
#

In the first image above, there is only 1 origin.
And there are 2 nodes.
In the second image, there are 2 origins. Something else is happening there

steep token
fathom vortex
#

Why does the first image have only 1 origin? From which of the 2 nodes is it?

#

(Well, there are 3 nodes with a 2D position. But i assume at least 2 of those are overlapping)

steep token
#

There are 3 of them: The CollisionShape, the Anim player and the Player Node

#

Which are centered perfectly

fathom vortex
#

In the second image they are not centered in the same position

steep token
#

However whenever i flip the Anim Player, it's not centered at all

fathom vortex
#

That is not normal. Changing the flip_h property does not affect the actual position of the node.
Are you flipping it trough the AnimationPlayer?

steep token
#

No

#

I flip it from the AnimatedSprite2D

#

And you can see, i use an AnimationTree

fathom vortex
#

The most likely thing happening here is that some animation is modifying the position of either the CollisionShape or the AnimatedSprite.
I do not have enough context for any other ideas.

steep token
#

Mhm....

#

And the problem is that all of my animations are on the right direction

#

And the flip works like that for all of my animations

fathom vortex
#

That should not matter much if the AnimatedSprite is properly positioned.
In my project i just use flip_h and it all works as intended.

steep token
#

Is it because it's not pixel art ?

fathom vortex
#

No. The position of the node is being moved by something

#

The fact that the second image has a node moved is the issue

steep token
#

The AnimatedSprtie2D is the problem

#

Look at the sixe of the box you will understand i guess

fathom vortex
#

The AnimatedSprite is not centered to the sprite there.

#

The orange cross should be in the middle of the samurai there

steep token
#

I know 😦

#

But what i did is artificial it remains the same

fathom vortex
#

The texture you used seems to have a bunch of empty space.
The texture itself should have the character in the middle. This is not set from the node necessarily

steep token
#

i guess it's the size of my canvas i used

#

I did my drawing with 1920x1080 size

fathom vortex
#

AnimatedSprite lets you customize the size of the canvas of the individual frame.
But it will be a pita if you have to do this for a bunch of them.

#

And it is done when adding the frame.

steep token
#

Yep very fun

fathom vortex
#

That is the AnimationPlayer

#

What i meant is fromt he AnimatedSprite

steep token
#

Yeah but it's just to show you that it will indeed take ages

#

But yeah i will show you the AnimatedSprite2D

fathom vortex
#

Does the sheet have a LOT of sprites?

steep token
#

It goes from 1 to 24 frames

#

not for all animations

fathom vortex
#

Do any of those animations have the same set of sprites? Because if so you can just delete the duplicates.

#

You do not need an AnimatedSprite animation per AnimatedPlayer animation necessarily

steep token
#

At every 1st frame i put my idle animation as a basis for my drawings

#

The one you saw earlier

steep token
fathom vortex
#

For example, if 2 animations from AnimationPlayer use the same set of frames. You can use the same set of frames for both.

#

With set of frames i mean AnimatedSprite animations

steep token
#

Ah i see, but the problem is, that every animations are unique and there are rarely or for most of them not the same set of frame

fathom vortex
#

Damn, best of luck.

steep token
#

Just, how can i resize them ?

#

Because when i resize the sprites, he becomes a pizza

fathom vortex
#

You have to modify the texture for each frame, and make sure the character is in the center of each.

steep token
#

The texture...

fathom vortex
#

The image files.
You'd have to modify each of them, then re-add them to each animation.

steep token
#

All right

#

Thank you

steep token
#

I found a quicker way eheheeh

#

Do you see the Offset on the AnimatedSprite2D ? I just have to increase the Offset value on the inspector and it's good, on x axis

fathom vortex
#

I imagined that would apply when flipped too.
But if it works then that's great!

steep token
#

I will tell you

#

But i hope it works

#

You're right it applies too 😦