0 votes

Hi. The PhysicsServer class allows me to create rigid bodies and applying force to them etc. without creating nodes.

Question is: How do I remove/delete a body I created via PhysicsServer.create_body?? There is no PhysicsServer.remove_body(). You can only remove shapes. I am using this for projectiles. A minute into the game, with hundreds or thousands of bodies having been created in this way the engine starts choking. I want to be able to remove a body after, say, It has flown an x distance away from its spawn position. How do I 'free' a physicsserver body??

Godot version 3.4
in Engine by (506 points)

2 Answers

+2 votes
Best answer
by (3,870 points)
selected by
–1 vote

You need queue_free()

so the code would be something like

by (3,027 points)

It's not a rigid body. It's not even a node. It's a RID. queue_free doesn't work with RIDs in physics servers.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.