godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.83k stars 21.14k forks source link

RigidBody2D and moving platforms #40495

Open luccapedrini opened 4 years ago

luccapedrini commented 4 years ago

Godot version: Godot 3.2.2 (also tested in 3.2.1)

OS/device including version: Windows 10 (Tested with both 2D physics engines)

Issue description: I'm trying to make a 2D platformer that is very physics dependent (so I need to use a RigidBody2D), when the player jumps I use apply_central_impulse() and the player loses control until it hits the ground again.

All of this mentioned above works almost perfectly, but when the player interacts with other moving bodies (Kinematic or Rigid) this happens: https://imgur.com/a/dHyNUxr Bugsquad Edit: Added 10s clips of the videos in the link Up-Down-Trimmed Left-Right-Trimmed

I'm using the template project so it's easy to reproduce, but you can go ahead and test with any changed configuration and it still gives somewhat the same behavior.

Steps to reproduce: RigidBody2D on top of any moving Body.

Minimal reproduction project: Not gonna upload the project since it's an official template,

Template name: 2D Physics Platformer Demo (RigidBody) Version: 3.2.2

luccapedrini commented 4 years ago

I would like to use this issue to raise up some questions about the topic above. (please mark as off-topic if this isn't the place to talk about this)

1. Is the problem with tilemaps liked above worth an issue (didn't post since it looks like is an known one)

2. RigidBody2D in Kinematic Mode is bugged, or bad documented The way i'm solving the issue above is, I'm instantiating and queue_free()ing a RigidBody2D and KinematicBody2D as needed. This would be an way easier task (and a cleaner code) if the Kinematic Mode worked as a KinematicBody2D. I don't know why thats not the case but if you search online there are a number of people noticing the same.

3. Why isn't Godot focused on getting the 2D physics right? Edited: as liked by Calinou this topic is being discussed in another issue. I want to reiterate that I never demanded anything and as I said I understand that godot is an open-source project, I was just asking about the priority decision that is being presented to the community.

Calinou commented 4 years ago
  1. Why isn't Godot focused on getting the 2D physics right?

Please understand that Godot is community-developed. Most features are maintained on a best-effort basis; there is no warranty provided whatsoever. Still, physics will be refactored in 4.0 (https://github.com/godotengine/godot-proposals/issues/570).

madmiraal commented 4 years ago

when the player interacts with other moving bodies (Kinematic or Rigid) this happens:

@luccapedrini I've looked at the linked videos and I can't see anything that is happening that shouldn't be happening. Please be more specific.

luccapedrini commented 4 years ago

@madmiraal The player's collision shape going inside the platform on the first gif. And on the second one the player sliding as the platform move. I don't think I can explain any better than the videos, for me it looks pretty obvious that there's something unexpected happening but I don't know where exactly the problem happens in this situation if that's what you're asking.

madmiraal commented 4 years ago

When the platform is moving left-to-right the RigidBody is relying on friction to provide a force; so some degree of sliding due to inertia is expected. Related to #16450

When the platform is moving up-and-down, there is a delay between the RigidBody responding to the movement of the platform, because the RigidBody updates and the platform updates happen at different times. So, I'm not sure whether or not this is fixable. Related to #27652