+1 vote

I'm new at learning godot and i really need help with this :/

Whenever i walk "pressing" myself into a wall, my character really slows down. Is there anything i can do to solve this problem?

I've created my walls as a tilemap(no code, only a collision shape and the sprite)
(btw, sorry for my bad english)
my KinematicBody2D(my character sprite) code is:
.
.
extends KinematicBody2D

export var speed : int = 200

func physicsprocess(delta):
var direction = Vector2()

``````direction.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
direction.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")

if abs(direction.x) == 1 and abs(direction.y) == 1:
direction.normalized()

var movement = speed * direction * delta

move_and_collide(movement)
``````
in Engine

So, im guessing this is a top down game. If you dont want the character slow down or stops if colliding a wall, use `move_and_slide` insteado of `move_and_collide`.

I mean change this:

``````var movement = speed*direction*delta
move_and_collide(movement)
``````

By this:

``````var velocity = speed*direction
velocity = move_and_slide(velocity)
``````

Note that move and slide internally multiplies for delta, so i changed movement by velocity and avoided multiplying for delta there.

by (3,505 points)
selected by

Thank you very much! It solved my problem :))