0 votes

There is a stage at the entrance with three objects:

  1. Wall (StaticBody2D) - brown square
  2. Character (KinematicBody2D) - blue square
  3. Enemy (RigidBody2D) - red square

There are 2 quotes:

  1. The character is removed from the wall at some distance (in the
    picture it is 1 px). The enemy moves towards the character and upon
    reaching the character is removed.

  2. The character is located close to the wall. The enemy moves towards
    the character and upon reaching the character is NOT deleted
    (although it is expected to be deleted).

Collision detection method:

func _physics_process(delta):
    var collision = move_and_collide(velocity * delta, false)

    if collision:
        if ("enemies" in collision.collider.get_groups()):

Two situations in the pictures:

The initial state of the scene before the enemy moves
The enemy moves from right to left
start scene

The final state of the scene after the end of the enemy's movement.
end scene

It can be seen that in the second version the character is removed, because did not touch the wall, but the character remained when he stood close to the wall

Q: Is this correct or wrong behavior?

Q: What can be done so that a collision with an enemy is determined despite the fact that the character is standing close to the wall?

After some time
If you use RigidBody for the character, then everything works.
Note: if you have set character parameters RigidBody2D ContactMonitor = true and ContactReported = 1.

Q: Is this the only solution?

Godot version 3.4.4
in Engine by (16 points)

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.