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?

in Engine by (355 points)

You can't check for collision using StaticBody

In every engine out there, static bodies do not report anything:

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

by (7,888 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?

by (355 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.
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.