0 votes

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

in Engine by (402 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

by (20,923 points)
selected by

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.