Godot Version
4.3
Question
I’m trying to make it so that the player can push an object, pick it up and stand on it. it seems to have worked, but if the player first stands on an object, and then tries to interact with it, then the object remains in place.
My object is rigidbody2d and has a layer 3 and a mask 1, 3. The player has a layer 1 and a mask 1, 2.
So that the player can stand on it and not fall through, I made a small collision of the player, which, when colliding with an object, does this:
func _on_area_2d_body_entered(body):
if body.is_in_group("item"):
body.collision_mask = 3
body.collision_layer = 3
when the interaction disappears:
func _on_area_2d_body_exited(body):
if body.is_in_group("item"):
body.collision_mask = 2
body.collision_layer = 2
body.collision_mask = 1
body.collision_layer = 1
I guess the problem is that after a collision, the object layer does not return to its initial state.
It seems so simple, but I’ve already tried everything and I couldn’t solve it. Please help me and explain what’s wrong