Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Starlight_Chronix |
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 JUMP_SPEED = 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():
$AnimatedSprite.play("Run")
else:
$AnimatedSprite.play("Jump")
move_and_slide(velocity,Vector2.UP)
func _on_fallzone_body_entered(body):
get_tree().change_scene(“res://scenes/TitleScreen/Title Screen.tscn”)
thanks in advance