I don't know how to "get_slide_collision" to detect collision between player and the enemy, can someone please tell how?

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

I have ready the get_slide_collision example at https://docs.godotengine.org/en/stable/classes/class_kinematicbody2d.html#class-kinematicbody2d-method-get-slide-collision
but I am unsure of how to implement it into my script.

:bust_in_silhouette: Reply From: Dexter_

Perhaps this will do it:

for i in get_slide_count():
		var collision = get_slide_collision(i)
		if collision.collider.name == "Player":
               DoSomething

Change “Player” to what your player node name is and tell me if it does what you want!