Offset KinematicBody in a collision with an obstacle

: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 continuation of the question: How to find out about collisions with StaticBody - Archive - Godot Forum

Really need the help.

enter image description here

_fixed_process” I cyclically is called a “move” for the door. I move the door only on the Y-axis. But the collision with the game character causes displacement of the door along other axes. This is tantamount to the destruction of the location.

Tell me how to avoid it.

You keep calling move when the door hit the character?
Because if the move hits a body and the body keeps pushing (rigid body in particular), move will try to get the door out of overlapping, displacing it on other axis.

Using set_translation is better if the door needs to push/ignore other bodies.

If you need to use move so it stops, you can try like some “real” doors and move it a bit up when is_colliding or just stop moving it if is colliding.

eons | 2017-01-17 18:01

If you need to use move so it stops, you can try like some “real”
doors and move it a bit up when is_colliding or just stop moving it if
is colliding.

I’m trying to do. But this does not preclude the displacement of the door in the space when it rises after the collision (when the character is not under the door and presses on her front).

Using set_translation is better if the door needs to push/ignore other
bodies.

set_translation I definitely like it more. But in this case is_colliding not see the collision. This is possible using set_translation to know about the clash?

The point is that I tried both ways.

DimitriyPS | 2017-01-17 21:02

:bust_in_silhouette: Reply From: eons

I’ll answer for the use of translation because i’m not sure what happens with move (need to test that, could be a bug with that method).


Since using set_translation won’t toggle the colliding flag, it will need the help of another node…

You can add a couple of raycasts below the door, the amount, length and location of the rays will depend on the door movement, speed and the shapes of bodies to intercept, iterate the rays for their is_colliding.

Another option is to add an area below the door (a small one or all the frame) and check get_overlapping_bodies (for the size and type/group of the bodies) or the signal body_enter to stop the door and/or make it open.

And… you can make the bodies that touch the door tell the door they are below, but it will depend much on the design because the character may be touching stuff all the time and that check may turn a bit inefficient.

All of a sudden artificially complicated.

The method “move” makes possible is_colliding. It is possible to make other call is_colliding what would he work?

DimitriyPS | 2017-01-18 07:03

Just with the help of raycasts or an area to detect something below before collision as I have explained, is not more complicated, just need to check is_colliding or get_overlapping_bodies on the door children instead of the door itself.

eons | 2017-01-18 20:39

an area to detect something

I’m not familiar with it, please tell me what it is?

DimitriyPS | 2017-01-18 20:46

The node Area works as a basic overlap detection zone (among other uses), it can use body_enter signal to know if some body (or area) is entering or get the list of overlapping bodies.

A small detection child Area below the door could be used to tell the parent door to stop going down if something is in it.

Door (script)
   |-mesh
   |-shape
   |-Area (at the bottom of the door, with signal to the door)
        |-shape (to detect stuff below the door)

One example of basic use of Areas is the “princess” on the Kinematic Character 3D demo, and is similar to Area2D on other demos.

eons | 2017-01-18 22:10

eons, thank you so much!
I was able to solve his problem!
I first mastering the physics engine. Therefore, even simple things cause problems. You really really helped!

DimitriyPS | 2017-01-19 20:06