godot-jolt / godot-jolt

Godot Jolt is a Godot extension that integrates the Jolt physics engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Area3D entered and exited inconsistent with Jolt Physics

Vityy opened this issue · comments

Tested versions

Reproductible in 4.2.1 Mono with Jolt Physics as 3D physics

System information

Godot v4.2.1.stable.mono - Windows 10.0.22631 - Vulkan (Forward+) - dedicated AMD Radeon RX 6800 (Advanced Micro Devices, Inc.; 31.0.23013.1023) - AMD Ryzen 7 5800X 8-Core Processor (16 Threads)

Issue description

When using Jolt Physics, when a CharacterBody3D enters an Area3D both "Entered" and "Exited" signals are triggered at the same time making it impossible to use Area3D correctly.

The same thing happens with "AreaEntered" and "AreaExited" signals when trying with an Area3D.

Didn't test with RigidBody3D and StaticBody3D

If you move the animatable body that is the parent of the Area3D the characters is detected as exiting and entering multiple times even if it doesn't move and stays stuck on the platform
Steps to reproduce

-Create an Area3D with a CollisionShape
-Create a moving CharacterBody3D (or Area3D)
-Connect "on_body_entered" and "on_body_exited" signals to a script on the Area3D that trigger a print on debug console
-Playtest, enter the Area3D with the CharacterBody3D
-You'll see both signals triggered at the same time, it considers that your CharacterBody3D is already out of the Area even if it isn't

Minimal reproduction project (MRP)

https://we.tl/t-4Q5NMSWdq1

Download link (ZIP was more that 25 MB)

You'll see both signals triggered at the same time

I'm running your repro, but I'm not seeing this behavior, no matter which of the areas I try to walk into.

Is there anything else I have to do?

(I am however seeing some jank when being pushed by that TrapWall thingy, which doesn't seem to happen with Godot Physics, but that's unrelated to this I guess.)

Hey!

For the jank I don't think it's related but would be good to investigate too, as for the Area3D I don't know what happens but after I restarted my computer it suddenly works.

Apart for the fact that the player is detected as entering and exiting the area when the lift goes down, the entering and exiting seems to be working fine now.

I don't know what was happening before that or if you can reproduce it, Maybe try in a fresh new project.

Apart for the fact that the player is detected as entering and exiting the area when the lift goes down, the entering and exiting seems to be working fine now.

You mean as it's descending or once it's hit the ground again? I'm not seeing either of these. For me it acts as expected, where you get an enter event when you step onto the lift and an exit event when you step off.

Try to stay on the lift when it goes up and when it's descending take a look at the debug console (activate the gizmo in game you'll see that you never exit the area3D collider), you'll see that you enter and exit the area3d multiple times.

That is also happening with Godot default physics but it seems strange to me that it happens in the first place :)

I am seeing something like that if I make the area's height a bit shorter, like 0.5 m. In that case it exits as it starts descending and enters once it's hit the bottom, which I suppose might make some kind of sense if the area's step size is greater than the overlap between it and the character. The fix there would be to just make the area taller.

You might also want to change the process mode of your tweens to be tween.set_process_mode(Tween.TWEEN_PROCESS_PHYSICS) since they're modifying the positions of physics objects, otherwise you'll potentially get very different outcomes on different machines, which might explain some of the differences we're seeing.

Anyway, given that the issue happens with Godot Physics as well it's unlikely to be an issues with this extension, so I'll go ahead and close this.

Ok thank you for the intel, I'm kind of new to Godot 4 and Jolt physics. Thank you for the fast answer and help.

Just tried making the area collider bigger than the character capsule and it indeed worked. Was used to Unity not working the same :)