Why does my movement speed need to be set so high?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By YangTegap

I’m just learning Godot. This works perfectly for a basic character controller, but can someone help me understand why my constant SPEED needs to be set so high for adequate player speed? 10X higher than gravity?

extends KinematicBody2D

var velocity = Vector2()
const SPEED = 10000
const GRAVITY = 1000
const JUMP = 500


func _process(delta):
	_get_input(delta)

	velocity.y += GRAVITY * delta
	velocity = move_and_slide(velocity, Vector2.UP)

func _get_input(delta):
	var movement = -int(Input.is_action_pressed("left")) + int(Input.is_action_pressed("right"))
	velocity.x = movement * SPEED * delta

	if is_on_floor():
		if Input.is_action_just_pressed("space"):
			velocity.y -= JUMP
:bust_in_silhouette: Reply From: exuin

This is because you’re multiplying it by delta, which is the time since the last frame in seconds, so it’s a very small number. The move and slide function automatically multiplies the argument by delta itself so it’s being multiplied by delta twice. Don’t multiply the speed by delta.

Oh! I didn’t realize that about move_and_slide. Thank you!

YangTegap | 2021-06-23 20:11