Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | wentdot |
I am writing a very small project and I use move_and_slide to move my character. But somehow it feels very “lagging” (allthough on the FPS counter you can see that it isn’t actually lagging). It looks as if it collides with something for quite a while and after some time somehow resolves the collision. In the example below I always press right all the time, then left all the time, then right all the time etc. The moments where he halts I do not let go of the movement key and keep it pressed until it moves again.
Here is a gif of the behaviour: https://giphy.com/gifs/L0rpubzitsYILpAptx/fullscreen
(I tried to inline it but I had no luck, sorry)
Does anyone know what could be wrong?
EDIT: Full project, zipped: https://files.fm/u/32dw9mtm
The part where I use move_and_slide, in my KinematicsBody2D node:
`
var velocity = Vector2()
func _physics_process(delta):
velocity.y += delta * GRAVITY
if Input.is_action_pressed("ui_left"):
velocity.x = -WALK_SPEED
elif Input.is_action_pressed("ui_right"):
velocity.x = WALK_SPEED
else:
velocity.x = 0
move_and_slide(velocity, Vector2(0, -1))``
It’s hard to tell you what may be wrong without seeing your code. Please post the code for the player where you’re using move_and_slide()
.
kidscancode | 2018-02-22 01:29
thank you for answering, I edited my question
wentdot | 2018-02-22 08:57