1
\$\begingroup\$

Consider the player with a rectangular CollisionShape2D:

player

and a round enemy with a CollisionShape2D and a little bigger Area2D:

enemy

I observe frequent collisions with no body_entered signal sent by the enemy area.

I have tried to reduce the radius of the collision shape in the enemy. It works, but enemy behavior against walls is not satisfaying anymore.


Edit

My question was unclear... Bouncing is not appropriate to describe what is happening.

Player and Enemy are KineticBody2D.

After some reflection, I have an hypothesis:

Maybe it is because Enemy changes x direction each time _is_on_wall() which means that he changes direction when he hits the player too.

Anyway, if changing direction is the cause of the absence of detection of the player Body by the enemy Area, for the player and enemy to collide, the body of the player must be in the area of the enemy.

For @Theraot remark on adding on Area to the player, I have decided to leave to the enemy the responsability to detect and damage the player, because it is easier to make type of enemy this way I presume.

\$\endgroup\$
1
  • \$\begingroup\$ Still can't get this to fail for me. I set two KinematicBody2D using move_and_slide in _physics_process, changing direction when is_on_wall() is true, bounded by StaticBody2D. And I give them both a child Area2D with a CollisionShape2D slightly bigger than the CollisionShape2D of the KinematicBody2D. And both Area2D register the KinematicBody2D and StaticBody2D on body_entered \$\endgroup\$ – Theraot May 10 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.