0 votes

I have multiple KinematicBody2Ds moving in the game screen randomly. I want these bodies to overlap and move and then stop slowly. But I dont want them to overlap when they stopped. So I want to check if they have any overlap they continue moving. The problem is I cant find any way to check overlap or find overlapping bodies!
This is my node structure:
- Sprite
- CollisionPolygon2D

When I use collisionPolygon my bodies do not overlap. So I disabled collisionPolygons.
All of these bodies are child of an area2D node. I tried using getoverlappingbodies but it always returns 0 object.
I'm just so much confused! Can someone explains what should I do?

in Engine by (14 points)

1 Answer

0 votes

You can use an Area2D.

it has a signal area_entered
or you can also use the method get_overlapping_areas.

by (1,480 points)

I used moving functionalities of kinematicBody2D like moveandslide. Does area2D have similar functionalities?
Isn't there a method to detect overlap between 2 kinematicBody2D?!

You can put the bodies that should not collide but overlap into different collisionlayers(/masks) and just add the area2D as a child to you kinematicbody2d, so it will move with it :)

This method works :))
Thanks a lot.
Solved my issue.

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.