0 votes

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)
Godot version v3.0.6.stable.custom.build
in Engine by (15 points)
edited by

1 Answer

+1 vote
Best answer

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?

by (22,067 points)
selected by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.