I have a KinematicBody2D, to move it I use the function
speed is a
Vector2, and it has simple gravity:
var spd = 500
var acceleration = 10
var jmpSpd = 800
var GRAVITY = 1300
var speed = Vector2()
if Input.is_action_pressed("btn_jump") and is_on_floor():
speed.y = -jmpSpd
var desiredSpeed = 0
desiredSpeed = spd
desiredSpeed = -spd
speed.x += (desiredSpeed - speed.x)*acceleration*delta
speed.y += GRAVITY*delta
speed = move_and_slide(speed)
The problem is that sometimes the player jumps higher than it should, and falls faster, and moves faster, this generally only happens when I have just turned on my computer, which makes me think that it has something to do with the number of times
_process(delta) is called, but I have no idea.
Maybe I should use
move_and_slide(speed*delta), but then I would need very big values for all the variables, and when using
move_and_slide(speed) I get results much more similar to Godot 2 (this tutorial).
What should I do?
Thanks in advance