Godot: KinematicBody2D Will Suddenly Launch RigidBody2D

Created on 6 Jan 2020  路  4Comments  路  Source: godotengine/godot

Godot version:
v3.1.2.stable.official

OS/device including version:
Windows 10 x64

Issue description:
When colliding with a rotating KinematicBody2D, a RidigBody2D will suddenly go launching.

Velocity of the RigidBody2D:
image

Scene settup:
image

Steps to reproduce:

  1. Create a KinematicBody2D
  2. Create a RigidBody2D
  3. Give the KinematicBody2D collision shapes that surround the RidigBody2D
  4. Create a script to rotate the KinematicBody2D
  5. Start scene and wait.
  6. RigidBody2D will suddenly teleport from a massive spike in velocity.

Minimal reproduction project:
velocity_issue.zip

bug physics

Most helpful comment

So, I've been experimenting with this issue. And I believe it's caused when the kinematic body manages to clip through the rigid body. The physic engine then aggressively separates the two objects.
image

It's worth noting that the issue seems to be less severe the slower the object rotates. Additionally, using a polygon collision set to Segments also shows a reduction in launching.

All 4 comments

I confirm, the same thing happens when the rotation of the kinematic body is controlled via animation player (with process mode set to physics): velocity_issue.zip

So, I've been experimenting with this issue. And I believe it's caused when the kinematic body manages to clip through the rigid body. The physic engine then aggressively separates the two objects.
image

It's worth noting that the issue seems to be less severe the slower the object rotates. Additionally, using a polygon collision set to Segments also shows a reduction in launching.

The main cause that i found is that the rotation of the kinetic body jumps from -Pi to Pi. This accelerates any touching rigid body way too much.

I have an updated demo project that shows what @Icekey is talking about. Using the following code inside the KinematicBody2D script:

extends KinematicBody2D
func _ready():
    print("READY: ", rotation)


var t = 0
func _physics_process(delta):
    if t <= 2:
        t += delta
        if t > 2:
            print(deg2rad(0.1))
            rotation -= deg2rad(0.1)
            print("Launch: ", rotation)

The KinematicBody2D doesn't appear to move, but will suddenly launch the dynamic body. However, it seems that for some reason the rotation actually goes from -PI to -PI if this output is to be believed:
image

Additionally, this same effect can be achieved by rotating the KinematicBody2D by 2PI. Therefore, it's likely Godot's physics thinks the object has been rotated 360 degrees and has collided with the DynamicBody.

physics_bug.zip

Was this page helpful?
0 / 5 - 0 ratings