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

RigidBody2D passes through walls/objects when pushed by a KinematicBody2D #27652

Closed
Tracked by #45334
TheRadMatt opened this issue Apr 3, 2019 · 17 comments
Closed
Tracked by #45334

Comments

@TheRadMatt
Copy link

Godot version:
3.1

Issue description:
Rigid Bodies pass through walls when pushed by Kinematic Bodies. This doesn't happen in 3.0.6.

In 3.0.6: https://i.imgur.com/k7vJdoM.mp4

In 3.1: https://i.imgur.com/BhkKt0G.mp4

It doesn't just happen in the platformer demo, I noticed this problem in other projects as well.

@akien-mga akien-mga added this to the 3.2 milestone Apr 3, 2019
@xiico
Copy link

xiico commented Apr 4, 2019

The same thing is happening to me, but in my 2D project.

3.0.6
3 0 6

3.1
3 1

@ghost
Copy link

ghost commented Apr 4, 2019

Similar experiences, and with CCD enabled they can still tunnel.

@takhimi
Copy link

takhimi commented Apr 4, 2019

Happens to me on my 3D game project also.

@TheRadMatt
Copy link
Author

Is there a possibility this will be fixed soon (in 3.1.1, perhaps)? The Rigid Bodies are basically unusable because of this and 3.2 won't come out for quite some time probably.

@rogeriodec
Copy link

rogeriodec commented Apr 4, 2019

My objective: to prevent a RigidBody (or KinematicBody) from "crossing" the StaticBody (like a wall or floor).

I have a script that "pushes" a RigidBody (Cube) with the mouse.
I inserted a print (RigidBody.get_translation ()) into func _input ( to detect any movement of the mouse by pushing the RigidBody.

And I connected a body_entered signal in the RigidBody to show any RigidBody collision with the floor (StaticBody).
As you can see in the animation, in the beginning, the RigidBody is resting (in a collision) with the StaticBody.
Then I start to push the RigidBody down and as you can see, the body_entered signal fires only multiple _input events after.

In my understanding, the body_entered signal should be triggered at the very moment the collision occurs. But this does not seem to be happening.
How to solve this?

@Zireael07
Copy link
Contributor

Body_entered fires every time the other body is entered. I don't know what the resolution of the check is, why it detects so late.

Check not only for body_entered, but also for a boolean of your own creation.
Switch the boolean the moment body_entered first fires.

@rafaelgdp
Copy link

I'm here to confirm that this also happened to me in a simple 2D project I was implementing. A KinematicBody2D pushes the RigidBody2D through walls and floors as if it were nothing.

@ghost
Copy link

ghost commented Apr 5, 2019

Is there a possibility this will be fixed soon (in 3.1.1, perhaps)? The Rigid Bodies are basically unusable because of this and 3.2 won't come out for quite some time probably.

Not too likely. I wish I could say otherwise, but personally I have benched these for most uses since 2.1, and over the previous year I have the impression it is an area that lacks contribution.

Juan may dabble a bit in the 2D physics here and there to patch things up, and it is something he talks of fully rewriting, but it has been bumped to the next version with each stable release. He may be the only one currently that can take the job on, but I imagine his priorities are necessarily between things like rendering work and general maintenance.

@takhimi

This comment has been minimized.

@takhimi
Copy link

takhimi commented Apr 5, 2019

Maybe this hopefully could resolved the problem ? #27415

@slapin
Copy link
Contributor

slapin commented Apr 5, 2019

This seems not physics related as does not happen with normal Bullet physics objects with separate project. I think a problem is due to infinite inertia and other stuff related to KinematicBody. It is very hard to implement collision so that it prevents Kinematic-Rigid collisions as it hits RigidBody with inadequate momentum. Would be nice if it was possible to avoid collisions completely (consider RigidBody a wall) or be able to override momentum or mass and force for Kinematic-Rigid collision.

@slapin
Copy link
Contributor

slapin commented Apr 5, 2019

I think there is a need for tutorial for dynamic character controller based on RigidBody as for other engines, this will make collisions much more natural. Dunno how to merge that with root motion but as NaughtyDog did that I think everybody else can do it too.

@ghost
Copy link

ghost commented Apr 6, 2019

@slapin At least for 2D, one isn't going to have much success at creating a stable and reliable dynamic body character of any complexity with the presently outstanding issues. I'm not sure what the state of affairs is for 3D.

@hiulit
Copy link

hiulit commented Jul 5, 2019

Same here #27593

@rdmtt
Copy link

rdmtt commented Aug 9, 2019

Turns out the problem is with infinite_inertia value which was introduced as an addditional parameter in move_and_slide function in 3.1. In order to fix the issue, you need to set it to false and then write code that will move rigid bodies on collision with the kinematic.
Thanks to KidsCanCode for figuring this out (his video).

I wish someone announced that there was a new parameter added :/ It would save some of us a lot of confusion.

Edit: Also, I believe this parameter should be set to false by default in the next releases.

@rafaelgdp
Copy link

I also saw this video @rdmtt ! I always thought this infinite inertia aspect of Godot's Kinematic Bodies had something to do with this weird behavior, but I never got to investigating it further! KidsCanCode rocks!

@akien-mga
Copy link
Member

This is indeed not a bug but a configuration option as pointed out by #27652 (comment).

This API has been improved significantly in 4.0 IIRC, so this might be less confusing now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.