error trying to recognize collision

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

It works fine when I intend to get the colsion up or down (0, -1) (0,1) but not with the right or left (1,0) (-1,0)
var col_info = move_and_slide (speed, Vector2 (0, -1))

if get_slide_count ()! = 0:
var body = get_slide_collision (get_slide_count () - 1)

if body.normal == Vector2 (1,0):
speed.y = 0;