godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.46k stars 21.07k forks source link

Area2D's signals *_entered and *_exited do not fire predictably during movement dependent on speed and size. #43743

Open julsams opened 3 years ago

julsams commented 3 years ago

Godot version: v3.2.3.stable.official

OS/device including version: Windows 10 Home 64-bit (10.0 Build 19041)

Issue description: Area2D's signals body_entered, body_exitedm, area_entered and area_exited do not fire predictably dependent on the size and speed of the objects involved.

Steps to reproduce:

  1. Create an Area2D segment that splits the viewing area.
  2. Create two RigidBody2D objects with a small circle as a child CollisionShape2D.
  3. Set their linear_velocity such that the two RigidBody2D objects move toward and pass through the segment.
  4. Increase the speed of one of them sufficiently and the signal will not fire anymore.
  5. Slowing down the object or increasing its size will cause the signal to fire again.

Minimal reproduction project: enter_exit_non_detection.zip

Calinou commented 3 years ago

This is yet another physics tunneling issue. Try increasing Physics Fps in the Project Settings.

pouleyKetchoupp commented 3 years ago

Confirmed on 3.2.3 and 3.2.4 beta 5.

Increasing the physics FPS a lot can fix the problem, but it can slow the game down by making physics run too many times for one game frame. Setting the rigid body to Continuous collision detection should help but it doesn't in this case, that needs to be investigated.

djrain commented 3 years ago

The same issue exists for a KinematicBody2D moving quickly, is this expected?

I'm not familiar with the inner workings, but it seems like KinematicBody2D uses some kind of CCD by default. So in theory, shouldn't it be able to reliably trigger any Area2D it passes through?

pouleyKetchoupp commented 3 years ago

@djrain It's probably expected, I don't think KinematicBody2D does proper CCD. But it should be added at least as an option.

AttackButton commented 1 year ago

Any chance to implement the https://github.com/godotengine/godot/pull/69934 and https://github.com/godotengine/godot/pull/70160 for Area2D and Area3D? At least as an option on the editor (for performance reasons).

The problem at the moment is that area nodes only trigger the body_entered or area_entered signals 6 or 7 frames late.

I don't think changing the physics ticks is the best solution for this.

Torguen commented 1 year ago

Shouldn't this have a milestone 3.6? I don't know, I see it as an important bug.

Torguen commented 8 months ago

Still in 3.6 beta 4

laurajayoconnor commented 7 months ago

This is yet another physics tunneling issue. Try increasing Physics Fps in the Project Settings.

This solved the issue for me by dramatically upping physics ticks per second to 1,000 and max physics steps per frame to 100. I'm not sure how these settings will affect slower machines but it has no obvious downside on mine.

Edit: I tested on my M1 Macbook which gets about 15% of the frames as my PC and it was still too slow detecting the mouse entering/exiting.

Torguen commented 7 months ago

I hope someone can solve it, I have it pending in my project and I have it marked as a pending bug although I applied a remedy I hope someone solves this.

https://discord.com/channels/212250894228652034/1114293117336690778

Torguen commented 4 months ago

Forgive my insistence but... I cry out to the gods so that some charitable soul can solve this. I hope that Godot 3 support is not ended with the existence of this bug!