+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,501 points)
selected by

Thank you very much! It solved my problem :))
{"ft_lang_label":"__label__en","ft_lang_prob":0.76360565,"math_prob":0.8986957,"size":795,"snap":"2023-14-2023-23","text_gpt3_token_len":192,"char_repetition_ratio":0.14791404,"word_repetition_ratio":0.0,"special_character_ratio":0.25408804,"punctuation_ratio":0.15789473,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9684633,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-05-28T02:33:03Z\",\"WARC-Record-ID\":\"<urn:uuid:a8868fff-f4f4-4cc9-b862-2fe80b5043b7>\",\"Content-Length\":\"29892\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d77efcf4-eec4-46d7-9607-1b8b4a5edd27>\",\"WARC-Concurrent-To\":\"<urn:uuid:da01af5d-e093-457e-874e-0753354c496f>\",\"WARC-IP-Address\":\"172.67.193.253\",\"WARC-Target-URI\":\"https://ask.godotengine.org/77833/may-have-some-help-discovering-how-to-stop-friction-on-walls?show=77868\",\"WARC-Payload-Digest\":\"sha1:F7GVI7VHWPX3PR6MLIC7R64BNUDM5J74\",\"WARC-Block-Digest\":\"sha1:OUCNJC6O3P6USP7GDELNYGWVTPYOSDD6\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224643462.13_warc_CC-MAIN-20230528015553-20230528045553-00211.warc.gz\"}"}