Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | hdc128 |
I have a CollisionShape2D
in a KinematicBody2D
, initially with CollisionShape2D.disabled = true
, so it doesn’t interact with anything. I want to find out if that disabled CollisionShape2D
is overlapping with another CollisionShape2D
(of a tile or of another KinematicBody2D
). I need this as then I could postpone calling CollisionShape2D.disabled = false
until it’s safe to do so (i.e., it wont cause the physical engine to “teleport” the kinematic body out of the overlapping position, or the body stuck inside a wall).
What did I try so far: I have tried enabling the shape, then calling KinematicBody2D.test_move(from, rel_vec)
, then disabling it if that has returned true
, But test_move
didn’t detect the overlap ifrel_vec
is small (it should be 0 in my case anyway). Well, it’s not a “move” what I want, so probably there’s a better solution anyway. I also wanted to try get_world_2d().direct_space_state.collide_shape(...)
, but then the game has crashed, so I couldn’t play around with that yet.