+1 vote

Hi, I'm looking for proper way for rotating objects and detecting collisions during this process. Rotation is quite fast.

I was trying rigid body and kinematic body (all in 2D) but most of the time collision is detected when objects are intersecting pretty much. Rotation was applied using setrotationdegrees and tween.

I will be appreciated for help :)

in Engine by (227 points)

1 Answer

+1 vote
Best answer

A proper way to rotate a RigidBody when using physics would be to use either add_torque or repeatedly calling apply_torque_impulse in _integrate_forces (or _physics process).

Anyway this works only well as long as the object does not (nearly) pass through a collision object in one physics time unit (=1/60th of a second unless configured different).

If you're faster then you'd have to "look ahead" using raycasts or other methods. Raycasts are used typically on fast, roughly straight moving objects (i.e. bullets) to see in "advance" what they will hit during the next physics timeframe. (To avoid they simply "skip" through a wall/opponent.)

Other methods would be (just an idea) to let an area rotate with the body which has a collision that covers the collision area "to come" and in case of something entering that area to calculate if something will hit the real body during the next time frame (using angular velocity and probably Transform2D).

by (3,258 points)
selected by

I just read on facebook about enabling "continuous collision detection " on the rigid body. Perhaps that is the easier solution.

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 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 webmaster@godotengine.org with your username.