How to find out about collisions with StaticBody

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DimitriyPS
:warning: Old Version Published before Godot 3 was released.

In my project there is an object here is a structure:

enter image description here

I need to check collision, how to do it?

You can’t check for collision using StaticBody

HatEm | 2017-01-05 16:48

In every engine out there, static bodies do not report anything:
https://godot.readthedocs.io/en/stable/tutorials/2d/physics_introduction.html#in-case-of-overlap-who-receives-collision-information


But the most important question, what will be colliding with the StaticBody and why you want to detect that?

Maybe knowing that others will be able to give better answers.

eons | 2017-01-05 16:55

This object is a “lift door”. I move it by changing the value of Y at root Spatial. I want in the event of a collision, to interrupt it lower and raise.

Probably not the best option to do static body. This is a test and the first experience. It needs to be done KinematicBodi?

DimitriyPS | 2017-01-05 21:49

:bust_in_silhouette: Reply From: eons

If your body need to move and stop when colliding, a kinematicbody moved by move could be what you want.

In the case of collision (check is_colliding after move) change the movement direction (moved by translation wont report collision).

Look at the player on the kinematic character 3D demo (similar to 2D) to see how to work with move and is_colliding.

Oh, and the body will need to be parent of the mesh to move it too (unless you update mesh position in another way).


And do some tests first, it seems that KinematicBody has mixed up collision layers and masks (I think that currently only checks layers as masks).

:bust_in_silhouette: Reply From: DimitriyPS

I did as you advised. Now the behavior of the door as I wanted. But I found another problem.

I have a method “move” move the door only Y. My player (RigidBodi) resting against the door during the cyclical calls of the “move” moves it along other axes. It breaks down the location.

What can I do about it?