0 votes

I've my charecter in the ground and everything works perfect, i'm wondering how can i make it "Ignore Gravity" so he can fly when i press a key, here's my code:

extends KinematicBody2D

const SPEED = 170
const GRAVITY = 10
const JUMP = -400
const FLOOR = Vector2(0, -1)
var velocity = Vector2()
var on_floor = false

func _physics_process(delta):
velocity.y += GRAVITY

Thnx a lot

asked Jun 6 in Engine by checharor (26 points)

1 Answer

+1 vote

Either, change gravity to a var and set it to 0 when flying.

Or

Have a flying bool and do something like:

if !flying:
    velocity.y += GRAVITY
answered Jun 6 by deaton64 (1,261 points)

Thnx what a simple solution

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.