0 votes

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

enter image description here

I need to check collision, how to do it?

asked Jan 5, 2017 in Engine by DimitriyPS (353 points)

You can't check for collision using StaticBody

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.

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?

2 Answers

0 votes

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).

answered Jan 6, 2017 by eons (7,759 points)
0 votes

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?

answered Jan 15, 2017 by DimitriyPS (353 points)
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.