![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | MadHatterGodot |
Hello i’m trying to make a 2D Platformer inside of godot right now and while codeing the movement for it the jump wouldn’t work i check my code and there was no errors. And is very confuseing for someone like me who switched from Unity to Godot so here’s the code
extends KinematicBody2D
const UP = Vector2(0,-1)
const GRAVITY = 20
const MAXFALLSPEED = 200
const MAXSPEED = 900
const JUMPFORCE = 1000
var motion = Vector2()
func _ready():
pass
func _physics_process(delta):
motion.y += GRAVITY
if motion.y > MAXFALLSPEED:
motion.y = MAXFALLSPEED
if Input.is_action_pressed("right"):
motion.x = MAXSPEED
elif Input.is_action_pressed("left"):
motion.x = -MAXSPEED
else:
motion.x = 0
if is_on_floor():
if Input.is_action_just_pressed("jump"):
motion.y -JUMPFORCE
motion = move_and_slide(motion,UP)