You could add a variable var flipped = 1 and multiply gravity by that GRAVITY * flipped, then when you want to trigger the flipping you simply invert it flipped = -1 so now your gravity is reversed, to make it last one second add a timer.
You would change (CONDITION) to what you need to trigger the reversing, such as a collision. If you are using a collision you can use a signal from the collision body to trigger the flipping and timer.
flipped can also be a float which can also be used to increase gravity at times (renamed to gravity_scale or something).
Dlean Jeans | 2019-07-28 05:18
Thanks! This helps loads, but when I use this and replace the (CONDITION) with collisionflip, it says: error(33,6): Identifier 'collisionflip' is not declared in the current scope. What exactly does this mean? Or does it just mean I have to have an existing signal with the output of collisionflip?
RuukasuDraw | 2019-07-28 18:42
You will need to implement some sort of collision checking mechanism. Since your using move_and_slide you can check for a collision with:
if get_slide_count() > 0:
collisionflip = true
this will cause it to flip gravity any time there is a collision. Or to limit it to some specific objects
for i in get_slide_count():
var collision = get_slide_collision(i)
if collision.collider.name == "specific object to flip with":
collisionflip = true
break
then add collisionflip = false at the end of the if (CONDITION): block.