Mirror flipping the charater

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

I want to mirror flip my character when changing direction whitout using animations. Any help? Thanks

It does not work… i get this error…
Invalid call. Nonexistent function ‘setfliph’ in base ‘KinematicBody2D (playerscript.gd)’.
If i write just fliph i get
Invalid call. Nonexistent function ‘fliph’ in base ‘KinematicBody2D (playerscript.gd)’.

GunPoint | 2017-08-04 17:46

:bust_in_silhouette: Reply From: kidscancode

Sprite has a flip_h and a flip_v property. You can just toggle them true/false when you change direction.

Maybe worth adding as a technical note, flipping also gets achieved when you set scaling values to -1.

avencherus | 2017-08-01 22:46

Another note, try to manage the visual nodes (like sprites) separated of the interactive ones (like bodies).

In case of using scales, some bodies may not like it or will directly revert it when processed (at least on 2.1, I have not tested 3 yet).
So, scale the visual and look for the best way to treat the main nodes (like centring or resizing shapes).

eons | 2017-08-03 04:10

It does not work… i get this error…
Invalid call. Nonexistent function ‘set_flip_h’ in base ‘KinematicBody2D (playerscript.gd)’.
If i write just flip_h i get
Invalid call. Nonexistent function ‘flip_h’ in base ‘KinematicBody2D (playerscript.gd)’.

GunPoint | 2017-08-04 17:45

You’re trying to call set_flip_h() on the KinematicBody2D. Note that above, I said that the Sprite node has these methods. You need to do something like:

get_node("Sprite").set_flip_h(true)

kidscancode | 2017-08-04 17:50

Oh right… Thank You!
BTW i like your YouTube channel :wink:

GunPoint | 2017-08-05 15:32