Kinematicbody2D collision not working

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

So i am working on a game where i want the character to automatically run in right and when he collides with an enemy to do something, and i just cant seem to fix the collision thing.

the code:

extends KinematicBody2D

var velocity = Vector2(150,0)
var speed = 1555
func _ready():
print(speed)
func _physics_process(delta):
var collide = move_and_collide(velocity* delta)
if collide:
print(speed)

i tried this but nothing gets printed, the player character is a kinematicbody2d and the enemy is also a kinematicbody2d, i tried with a staticbody2d too and isnt working.Thats the only script i have and its attached to the kinematicbody2d, im new into coding so i would be gratefull if anyone could help me and explain this to me

:bust_in_silhouette: Reply From: ramazan

Use

is_on_floor
is_on_wall
is_on_ceiling

if $KinematicBody2D.is_on_wall():
	print("lllllll")