0 votes

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

asked Aug 1, 2017 in Engine by GunPoint (395 points)

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)'.

1 Answer

+3 votes
Best answer

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

http://docs.godotengine.org/en/2.1/classes/class_sprite.html#class-sprite-set-flip-h

answered Aug 1, 2017 by kidscancode (17,704 points)
selected Aug 5, 2017 by GunPoint

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

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).

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 'flip
h' in base 'KinematicBody2D (playerscript.gd)'.

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)

Oh right... Thank You!
BTW i like your YouTube channel ;)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.