Why is my character moving slow?

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

My character moves slowly from side to side (ignore the cat, it’s an example of the real cat), I recently got into godot, here is my script:

extends KinematicBody2D

var screen_size
export var speed = 900
func _ready():
	screen_size = get_viewport_rect().size 

func _process(delta):
    var velocity = Vector2 (0,0)
    if Input.is_action_pressed("move_right"):
        velocity.x += speed * delta
    if Input.is_action_pressed("move_left"):
        velocity.x -= speed * delta
    if Input.is_action_pressed("move_up"):
        velocity.y -= speed * delta
    if Input.is_action_pressed("move_down"):
        velocity.y += speed * delta
		
    move_and_collide(velocity * delta)
:bust_in_silhouette: Reply From: kidscancode

You’re multiplying by delta twice - once when setting the velocity, and then again when passing it to move_and_collide(). 900 * 1/60 * 1/60 is 0.25, so you’re moving 0.25 pixels every frame.

Remove the delta from the statements where you set your velocity - that should just be speed.

Also, why are you using such an old version of Godot?

I have a government computer (juana manso) and I’m using the godot that comes with it, also, I don’t have the admin code and it doesn’t detect it, therefore, I can’t update or download the updates

Malbec | 2023-01-19 11:46