How to flip a rigged character with script

Godot Version

Godot v4.3.stable - Windows 10.0.19045 - Vulkan (Forward+)

Question

Is it possible to flip my rigged character with a script?

Hello. I just finished rigging my character with bones and animated the fella using Inverse Kinematics.

https://youtu.be/bUvJZZomIkQ

I tried to show as much in the video as I could. I would like to horizontally flip the character when moving to the right. But flipping the sprites themselves does not work because their pivot points are not in the center of the character but are at points where they have to rotate. One thing I need to mention too is that the pictures are not scales like the body parts they are all scaled the same I will send example pictures below so you know what I mean:



If anyone has any idea on how to fix this I would appreciate the help. If you need any additional information I will respond as soon as I am able to.

You can change the x scale of the parent node of the sprites to 1 for right and -1 for left.

2 Likes

You just need to change the scale.x of the parent node to -1
Try changing the CharacterBody2D.scale.x = -1

1 Like

You have to be careful with changing the size of physics bodies since it could break your physics. A work around for this is to just add an extra node2D as parent node for your sprite which you can scale then without having to worry about physics problems.

2 Likes

Thank you ^^

I will keep that in mind

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.