How to make smooth movement when colliding with walls in 2.5D game?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Digitijs
:warning: Old Version Published before Godot 3 was released.

I’m absolute beginner not only to Godot but also to game making in general.
I got in a little problem: when I’m moving diagonally against the wall, the movement is slowing down A LOT. How can I make it smooth so that it would be just as fast as if normally walking?

func _fixed_process(delta):
var motion = Vector2(0, 0)

#motion

if (Input.is_action_pressed("ui_up")):
	motion.y = -1
	RayNode.set_rotd(180)

if (Input.is_action_pressed("ui_down")):
	motion.y = 1
	RayNode.set_rotd(0)

if (Input.is_action_pressed("ui_right")):
	motion.x = 1
	RayNode.set_rotd(90)

if (Input.is_action_pressed("ui_left")):
	motion.x = -1
	RayNode.set_rotd(-90)

motion = motion.normalized()*MOTION_SPEED*delta
move(motion)

This is basically how I did movement using tutorials.

p.s. Also while I’m at it. When I have 2 walls 16x16 pixels and a gap between them the same size, I can’t move through the gap if the player has 16x16 collision. I simply solved that with changing his collision to 15x15 so it’s not a big deal, I guess

:bust_in_silhouette: Reply From: avencherus

I have two suggestions.

The fastest one is that you can turn off the friction on the walls, but only if this doesn’t give you other problems.

The other is that you will take the collision normal, and calculate a slide vector. This alters the direction every frame to move along the wall direction instead of into, as long as there is contact.

More can be read here in the Godot Docs: Kinematic character (2D) — Godot Engine (stable) documentation in English