Gravity Change + Flip

Hello Everybody,

I try to make a scene (only one scene, not a whole game) like VVVVVV. So far my code is working, but I don’t know how to “flip back”. When I press Space, the gravity changes and my Player-Gameobjects flips.
But when I press the key again, it doesn’t flip back (flipY => false), although the gravity changes again.

If anyone knows how to make my code fully working, please help me. I try to fix it since five days.

Thank you in advance.

I suppose you simply flip the SpriteRenderer and you work with gravityScale (from Rigidbody2D)? If so, let’s make it super simple then.

public SpriteRenderer mySprite;
public Rigidbody2D myR;

public void Update()
    mySprite.flipY = (myR.gravityScale < 0);