Skip to content

Jolt Physics - When Reparenting a CharacterBody3D, Area3D nodes that are elsewhere get triggered #113058

@AleMarcati

Description

@AleMarcati

Tested versions

  • Reproducible in 4.5.1 (didn't test other versions).

System information

Windows 10 - Godot v4.5.1.stable - Vulkan (Forward+) - NVIDIA RXT 3060 ti

Issue description

This bug apparently only happens when using Jolt Physics System:
Have a CharacterBody3D using MoveAndSlide(). Have an Area3D set at world origin (global position: 0, 0, 0).
Reparent the CharacterBody3D to some node near it, with KeepGlobalTransform set to true. Then Reparent it again to the Current Scene node, again with KeepGlobalTransform set to true. The Area3D that is at the world origin will trigger body entered even though the character is nowhere near the area 3D.

Steps to reproduce

Set project Physics System to JOLT.
Create a CharacterBody3D with a script using MoveAndSlide(). Place the character far from the World Origin.
Create another Node3D near the CharacterBody3D (this will be node you will reparent and unparent the character to).
Create an Area3D set at world origin (global position: 0, 0, 0), make its collider shape radius at least as big as the distance between CharacterBody3D and the Node3D it will be parented/unparented to.
Create a script that Reparents the CharacterBody3D to the Node3D with KeepGlobalTransform set to true when a key (Space in the MRP I provide below) is pressed, and Reparents it to the Current Scene node (with KeepGlobalTransform set to true) when another key is pressed (Left Ctrl in the MRP I provide below).

Using GD.Print for knowing when the area3D is triggered, we can see that when the CharacterBody3D is reparented from the Node3D back to the current scene node, it triggers the Area3D that is placed at world origin, even though the characterBody3D is never overlapping the area.
Calling Reparent() directly or deferred doesn't seem to make a difference for this issue.

Minimal reproduction project (MRP)

To test it: press Space bar to parent the CharacterBody3D to the other object (a RigidBody3D). Press left Ctrl to reparent it back to the current scene node. It's when reparenting to the current scene node that it will trigger the area 3D. The area3D is the big sphere positioned at world origin.

reparent-bug-minimal.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Up for grabs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions