KinematicBody2D - horizontal flip (with all of its contents)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bruteforce
:warning: Old Version Published before Godot 3 was released.

Hi,

I have a “walking” animation (from left to right).
This is a skeleton animation (with IK chain) in a KinematicBody2D.
How can I flip this KinematicBody2D (and every items inside) horizontally with gdscript?

I tried the set_scale(Vector2(-1,1)), but the result is a “moonwalking” character :slight_smile:

Thank you!

:bust_in_silhouette: Reply From: Curly Brace

i suggest putting sprites and possibly collisionshapes and rays into a sub node and flipping that subnode instead

:bust_in_silhouette: Reply From: jospic

In my code I’ve resolved in this way:

var currentScaleX
var currentScaleY

func _ready():

       var currentScale = self.get_scale()
       currentScaleX = currentScale.x
       currentScaleY = currentScale.y

func _process(delta):

	if (  move_to_right ):
		self.set_scale(Vector2(-currentScaleX,currentScaleY))
	elif ( move_to_left ):
		self.set_scale(Vector2(currentScaleX,currentScaleY))
	else:
		( idle )

-j

Ahh you’re right!
I used negative x in both directions… lol.

Sorry for the lame question, and thank you :)!

bruteforce | 2016-12-12 15:33