Yes, that looks correct. Here is what I see in my output:
Player/initially, collision_layer=1
Player/initially, collision_mask=6
Object/initially, collision_layer=2
Object/initially, collision_mask=1
Player/changed, collision_layer=1
Player/changed, collision_mask=4
Object/changed, collision_layer=2
Object/changed, collision_mask=0
The Object's gravity scale is set to 1 and is not changed. I'm wondering if it has to do with the method I am changing the collision layer/mask. Here is the full method that I have, which is triggered when the Object collides with the Player:
func _on_Object_body_entered(body):
var possible_hud_nodes = get_tree().get_nodes_in_group("HUD")
var hud_node = possible_hud_nodes[0]
if not hud_node._is_capacity_full():
print("Object has reached Player")
hud_node._on_pet_collected() # updates the HUD
queue_free() # deletes Object
else:
#print("Turn off layer masking to prevent collision from player")
print_debug("Player/initially, collision_layer=", body.collision_layer)
print_debug("Player/initially, collision_mask=", body.collision_mask)
print_debug("Object/initially, collision_layer=", collision_layer)
print_debug("Object/initially, collision_mask=", collision_mask)
set_collision_mask_bit(0, false) # changes the Object's collision mask
body.set_collision_mask_bit(1, false) # changes the Player's collision mask
print_debug("Player/changed, collision_layer=", body.collision_layer)
print_debug("Player/changed, collision_mask=", body.collision_mask)
print_debug("Object/changed, collision_layer=", collision_layer)
print_debug("Object/changed, collision_mask=", collision_mask)
I tried comment out the if statement and the code under it, but the sinking issue still persists.