why cant my charecter fall of a ledge

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Koce Angelov

Well basicly i have some little expirience with python and i heard gd script have alot of similar things to it so i read the godot docs and so far so good. I decided to start a project and ecrything seemed good things worked out for the most of the part and i almost compleated my basic movement. but when i come close to some ledge of my platform somenthing pulls me back i dont know why it is happening but im having a guess it has to do somenthing with my E_velocity variable.Its my first time using a game engine so i will realy apreciate the help and sorry if the code is messy or if it folows too much of python sintax.(also sorry for any spelling mistakes and such english aint my native)

extends KinematicBody2D

var velocity = Vector2(0,0)
const WSPEED = 195
var falling = 200
func _physics_process(idle):

velocity.y = falling

if Input.is_action_pressed("right"):
	velocity.x = WSPEED
if Input.is_action_pressed("left"):
	velocity.x = -WSPEED


move_and_slide(velocity)
velocity.x = lerp(velocity.x,0,0.2)

Maybe this

velocity.x = lerp(velocity.x,0,0.2) # LERP

ramazan | 2022-07-15 19:36

Я запустил этот код и у меня всё работает. На сцене точно нет чего-то, что может мешать?

USBashka | 2022-07-15 19:37

نعم ، يبدو الرمز جيدًا بالنسبة لي أيضًا ، لكنني أعتقد أن المشكلة تأتي من هيئة أخرى تتفاعل مع اللاعب

Maskass | 2022-07-16 19:01

:bust_in_silhouette: Reply From: Maskass

me too i’m new to godot and i have experience with python :smiley:

maybe there is another body in the edge of the platform
when a body with move_and_slide collides with another body, it will slide aong the other body rather than stop immediately

:bust_in_silhouette: Reply From: Maskass

me too i’m new to godot and i have experience with python :smiley:

maybe there is another body in the edge of the platform
when a body with move_and_slide collides with another body, it will slide along the other body rather than stop immediately