Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KinematicBody2D Will Suddenly Launch RigidBody2D #34869

Closed
Tracked by #45334
Capital-EX opened this issue Jan 6, 2020 · 5 comments
Closed
Tracked by #45334

KinematicBody2D Will Suddenly Launch RigidBody2D #34869

Capital-EX opened this issue Jan 6, 2020 · 5 comments

Comments

@Capital-EX
Copy link

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

@Xrayez
Copy link
Contributor

Xrayez commented Jan 6, 2020

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

@Capital-EX
Copy link
Author

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.

@Calinou Calinou changed the title KinematicBody2D Will Suddenly Lunch RidigBody2D KinematicBody2D Will Suddenly Launch RidigBody2D Feb 27, 2020
@Calinou Calinou changed the title KinematicBody2D Will Suddenly Launch RidigBody2D KinematicBody2D Will Suddenly Launch RigidBody2D Feb 27, 2020
@Icekey
Copy link

Icekey commented Mar 5, 2020

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.

@Capital-EX
Copy link
Author

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

@pouleyKetchoupp
Copy link
Contributor

Confirmed in 3.2.4, can't reproduce in 3.3 and later releases.

@pouleyKetchoupp pouleyKetchoupp added this to the 3.3 milestone Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants