Proper way for rotating objects with collision detection

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By websterek

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 set_rotation_degrees and tween.

I will be appreciated for help :slight_smile:

:bust_in_silhouette: Reply From: wombatstampede

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).

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

wombatstampede | 2019-02-14 15:09