0 votes

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! :)

in Engine by (15 points)

1 Answer

0 votes
Best answer

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"

by (18,209 points)
selected by

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

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.

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.