Simple KinematicBody2D help

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

I have a KinematicBody2D colliding with a StaticBody2D. The KinematicBody2D is to find out the name of the StaticBody2D. It’s simple, but I did not find out. I look forward to any help.

Some more information would be helpful:

Are you using Godot 2.1 or 3.0?

move_and_collide() or move_and_slide()?

kidscancode | 2018-02-03 07:52

I use Godot 2.1
I need move_and_collide() and move_and_slide()

Flo | 2018-02-03 08:00

Well, move_and_collide() doesn’t exist in 2.1, it’s a 3.0 function. In 2.1 you’d use move(), so I’ll answer assuming that’s what you’re using.

kidscancode | 2018-02-03 08:07

:bust_in_silhouette: Reply From: kidscancode

KinematicBody2D detects collisions when moving, so here’s an example using the move() function:

func _fixed_process(delta):
    move(velocity * delta)
    if is_colliding():

I found my problem. I wrote the script before themove() methods. I also needed the Is_move_and_slide_on_floor() method.

if is_move_and_slide_on_floor():
	var collide = get_move_and_slide_colliders()
	for body in collide:
		if body.get_name() == "Exit":

Flo | 2018-02-03 14:22