I am trying to understand the basic concepts of KinematicBody2D. Following is my code for movement of a sprite.
extends KinematicBody2D
const acceleration=50
const MAX_SPEED =200
var velocity = Vector2.ZERO
func ready():
setphysics_process(true)
func physicsprocess(delta):
velocity.x += (acceleration * delta)
velocity.x = clamp(velocity.x,-MAX_SPEED,MAX_SPEED)
move_and_collide(velocity)
I don't understand that when I am using move and collide method for movement, the sprite quickly moves out of the screen. But when using move and slide method(without multiplying acceleration with delta),the movement is slow and looks perfect.
I have also noted that when the velocity is set constant, the sprite movement is same using both method.