0 votes

I have a box and it is rigidbody.
I want the box can rotate when it near a wall.
However, rigidbody do not have moveandslide functionality so it will not rotate when the box near a wall.

So how can I solve the problem?
Is there any moveandslide for rigidbody?

Thank you

in Engine by (249 points)

What do you mean by "rotate when near a wall"?

I mean when the box adjacent to a box static body it cannot rotate

1 Answer

0 votes

Rigid bodies are not controlled like kinematics. move_and_slide is there to give your kinematic body a collision response. However, rigid bodies, because they are controlled by the physics engine, automatically respond to collisions by rotating, bouncing, etc.

When using rigid bodies, you don't control the body directly. You apply forces (add_force()) or impulses (apply_impulse()) to the body and the physics engine moves it appropriately. However, you must be careful to use these correctly.

See Using RigidBody2D for an introduction on working with RigidBody2D.

If you need a more specific answer, you'll have to share more details of your implementation.

by (21,712 points)

For example, I have two box adjacent together.
One is static body, and another one is a rigidbody.

I apply torque to the rigidbody and hope it can rotate.
However, since it is adjacent to the static body, the rotation seems blocked by the static body and hence the rigidbody does not rotate.

So my question is if I can work around it to make it rotate like the move_and_slide in kinematic body?

Thanks

is it impossible?

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.