• 2D
  • KinematicBody2d gravity?

Hello. Im just programming a new game with one problem: I made a KinematicBody2d node as a player and also a tileset, both have collisionshapes. I also tried to make gravity (the game will be a platformer) with this line:

extends KinematicBody2D

...

func _process(delta):
	...
	position.y -= delta * speed * -1

The Problem is: the player is falling through everything and i dont know how to fix it. It would be nice if smb could help me.

start from here adjust gravity, speed, jumping for your char add some friction move, coyote time, char spells, etc


const UP = Vector2(0, -1)
var MOTION = Vector2()
const GRAVITY = 10 
var SPEED = 80
var JUMPING = -200


func _physics_process(delta):
	get_input()


func get_input():
	MOTION.y += GRAVITY

	if Input.is_action_pressed("ui_left"):
		MOTION.x = - SPEED
	elif Input.is_action_pressed("ui_right"):
		MOTION.x = SPEED
	else:
		MOTION.x = 0

	if Input.is_action_just_pressed("ui_up") and is_on_floor():
		MOTION.y = JUMPING

	MOTION = move_and_slide(MOTION, UP,  true)  # true = stop_on_slope