set_as_top_level(true) produces weird behavior on CollisionShape3D. It appears as if the transform is not global but rather some kind of mixture of direct parent and parent.parent.
Toplevel false : proper alignement
Toplevel true : collision shapes position is changed by roughly half its displacement from local transform prior. Does not happen with the mesh, even if the mesh has an offset as well.
when the root objects position is changed and top-level is set true the displacement becomes even more pronounced. It appears as if the collisionshape adds the roots transform twice to its own transform.
when moving the root again with top-level set to true the mesh remains at its global position but the collisionshape moves along without changing its local space.
Setting top-level to false again moves the collision shape to its correct position
Node Setup : (it can also be a direct child of node3d and returns the same results)
Controls :
var toggle = false
func _physics_process(delta):
if Input.is_action_just_pressed("ui_accept"):
toggle = not toggle
label.text = "Toplevel : " + str(toggle)
mesh.set_as_top_level(toggle)
shape.set_as_top_level(toggle)
if Input.is_action_just_pressed("ui_left"):
global_transform.origin.x -= 1
if Input.is_action_just_pressed("ui_right"):
global_transform.origin.x += 1
Steps to reproduce
call set_as_top_level(true) on any collisionshap3d and move its parent object.
Godot version
4.0-beta 2
System information
Windows 11, Vulkan, RTX 3070 V. 516.94
Issue description
set_as_top_level(true) produces weird behavior on CollisionShape3D. It appears as if the transform is not global but rather some kind of mixture of direct parent and parent.parent.
Toplevel false : proper alignement
Toplevel true : collision shapes position is changed by roughly half its displacement from local transform prior. Does not happen with the mesh, even if the mesh has an offset as well.
when the root objects position is changed and top-level is set true the displacement becomes even more pronounced. It appears as if the collisionshape adds the roots transform twice to its own transform.
when moving the root again with top-level set to true the mesh remains at its global position but the collisionshape moves along without changing its local space.
Setting top-level to false again moves the collision shape to its correct position
Node Setup : (it can also be a direct child of node3d and returns the same results)
Controls :
Steps to reproduce
Minimal reproduction project
TopLevelCollisionShape.zip