How on Earth do I Detect Collisions?

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

Simple problem but I need to detect when and not when a KinematicBody2D is colliding with a StaticBody2D in GDScript. Is there a simple way to do that? I have looked through the Godot help and the documentation on the website but nothing seems to work. Step by step instructions would be nice. Thanks in advance if you can help! :slight_smile:

:bust_in_silhouette: Reply From: kidscancode

KinematicBody2D detects collisions in response to you moving it using move_and_collide() or move_and_slide().

There are step by step instructions here:

There’s even a section called “Detecting collisions”

I have already tried this. It did not work. I may have been doing something wrong I will go through it again.

Hopeijay | 2020-07-13 16:12

Well, the examples there are correct. Maybe if you shared a bit about what you’ve tried, we can figure out what’s not working. “It did not work” does not give any information to go on.

kidscancode | 2020-07-13 16:14

Ok, the collision.collider.name they were using there confused me because I just needed to use collision.collider. It works now thanks!

Hopeijay | 2020-07-13 16:28