0 votes

I have a problem. If i move the player with a or d it stutters at regular intervals. If i jump and still hold the buttons it stops until the player stops and this goes on and on.

extends KinematicBody2D

var velocity = Vector2(0,0)
const SPEED = 180
const JUMPFORCE = -300
const GRAVITY = 10

func physicsprocess(delta):
if Input.isactionpressed("right"):
velocity.x = SPEED
if Input.isactionpressed("left"):
velocity.x = -SPEED

velocity.y = velocity.y + GRAVITY

if Input.is_action_just_pressed("jump") and is_on_floor():
    velocity.y = JUMPFORCE

velocity = move_and_slide(velocity,Vector2.UP)

velocity.x = lerp(velocity.x,0,0.2)
in Engine by (12 points)

What is happening in your code when those buttons are released? Did you code that yet? If you use Input.is_action_pressed Then the behavior goes and continues after you hit that button. You should use Input.is_action_just_pressed Or even better Input.get_action_strength Or code an animation fix to Input.is_action_just_released. But try switching to Just pressed first and see if that helps.

Please log in or register to answer this question.

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.