I cant use queue_free

Hello. I made a project to tell you my problem

As seen here, the upper object will fall down and contact the lower one. Then the bottom one will be deleted. But it’s not working. The one above falls and pushes him. I’m new to Godot. Please help. (I Used google translate, sorry)

Do you have contact monitoring set?

body_entered(body: Node)

Requires contact_monitor to be set to true and max_contacts_reported to be set high enough to detect all the collisions

Sorry.I’m new to Godot and unfortunately I don’t understand what you’re saying. What is contact_monitor and max_contacts_reported?
Where can I look at them?

Properties of RigidBody2D, You can change them in the inspector, “Denetleyici”

I set contact_monitor for both. Now? Still not working.

Max contact monitor is zero for both

Okay! I did it! Thanks for everything. be safe sir.

1 Like

I think I have another problem.

I cloned both objects. But while the extinction code works on the originals, it doesn’t work on the clones. Is there a way to install scripts on clones?

Your original connection is odd, connecting from player2 to player1 Nodes. might be better to remove the editor’s connected signal and apply it via script like so. This will also work both ways, so any rigidbodies will be deleted when contacting each other.

func _ready() -> void:
    body_entered.connect(_on_body_entered)

func _on_body_entered(body: Node2D) -> void:
   queue_free()

I think to accurately help more I would need to know more of your goals for this project.

I say again that I generally use Google Translate.
I’m making a game where a random world is created when the game starts. And rocks and trees spawn randomly in the world. If the stone and the tree were to grow on top of each other(looks bad), the stone is erased. Likewise, if stone and stone come into contact, or tree or tree come into contact, both will be erased. But I noticed that it wasn’t working. I created the project above to test this. and I noticed. While the deletion code worked on the originals, it did not work on the clones.

1 Like

Thank you, that is helpful!

You need to make the connections after duplicating, in your case, the rocks should connect similar to the example I gave. You can make this a little shorter like so

var rock = $player.duplicate()

rock.body_entered.connect(rock.queue_free.unbind(1))
add_child(rock)
1 Like

Thanks but where do I write this? Node2D? Please show.

Uploading: Screenshot_2024-07-16-12-52-19-406_org.godotengine.editor.v4.jpg…

If you mention any of these, the project throws an error

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.