0 votes

I'm new to coding and making a endless runner game and coded in a jump input it works for the menu, then when the game plays my player runs then falls to his death. He could run on the platform but he isn't able to jump

here's the script

extends KinematicBody2D

const UP = Vector2(0, -1)
const GRAVITY = 5
const JUMPSPEED = 150
const JUMP
HEIGHT = -350
var velocity = Vector2.ZERO

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

if Input.is_action_just_pressed("Jump") and is_on_floor():
    velocity.y = JUMP_SPEED

if is_on_floor():


func onfallzonebodyentered(body):
gettree().changescene("res://scenes/TitleScreen/Title Screen.tscn")

thanks in advance

Godot version GLES3
in Engine by (17 points)

1 Answer

+3 votes
Best answer

Try making the constant jumpspeed a negative number.

by (3,029 points)
selected by
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 Frequently asked questions and 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 [email protected] with your username.