0 votes

How to nnable or disable rigid body at runtime?

in Engine by (35 points)

1 Answer

+5 votes

Depends on what you exactly mean with disable.

You could set sleeping to true. It should then stop moving unless it is hit by something.

You could set the mode to MODE_STATIC then it stays where it is and ignores all forces but other things can still collide with it.

You could set collision_mask and collision_layer to 0 or (alternatively) disable all collision shapes of the rigidbody. Then no collision would take place.

And naturally you can toggle the visibility. It might also be convenient to link actions which I named above to a visibility notification. All depending on what you exactly want...

by (3,350 points)
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.