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

Incorrect bounce angle of RigidBody2D when using the Cast Ray Continuous Cd mode #32138

Open
Tracked by #45334
GaidamakUA opened this issue Sep 14, 2019 · 10 comments
Open
Tracked by #45334

Comments

@GaidamakUA
Copy link

Godot version:
v3.1.1.stable.official
OS/device including version:
Mac OS X and Linux Ubuntu
Issue description:
RigidBody2d collides with flat StaticBody2d and bounces with random angle. Often, with the same it came from. Happens on relatively high speed of RigidBody2d
Steps to reproduce:

  1. Run the project
  2. Bump the RigidBody2d with KinematicBody2d so it's speed increases
  3. Observe the bug.

Here are the description with video and screenshots attached:
https://www.reddit.com/r/godot/comments/d4455z/bug_i_godot_physics_system/
Minimal reproduction project:
https://github.com/GaidamakUA/GodotExperiments/tree/master/arcanoid

@ghost
Copy link

ghost commented Sep 14, 2019

Setting "Continuous Cd" on the Ball to "Cast Shape" seems to make it behave correctly (tested with 3.2-alpha 24e1039). I couldn't tell you why though.

@GaidamakUA
Copy link
Author

Yes, I can confirm, it works with "Cast shape". Thanks. Just to give you a bit more context. I've tried to implement borders in previous version by collision shape in TileMap. And it behaved in a similar manner. And "Cast Shape" didn't work. You need me to make another sample project for that?

@ghost
Copy link

ghost commented Sep 15, 2019

@GaidamakUA Yeah that would definitely help, if it isn't too much trouble.

@GaidamakUA
Copy link
Author

GaidamakUA commented Sep 16, 2019

It's pretty same but collision is implemented via tilest
https://github.com/GaidamakUA/GodotExperiments/tree/master/arcanoid_tileset_collision
For this version Cast Shape doesn't fix the issue.
@Homer666

@Feniks-Gaming
Copy link
Contributor

https://www.reddit.com/r/godot/comments/eerh7a/why_is_my_bouncing_inconsistent/

I have the same issues in my project using 3.1

@maximinus
Copy link

I have exactly the same issue. I would guess the object is travelling inside the static body and this is causing it to lose accuracy somewhere. I have seen this on Windows 10 and Linux. The issue can be reduced somewhat with a slower moving object and "Cast shape" a little better but cannot remove it totally.

@Feniks-Gaming
Copy link
Contributor

I can confirm what @maximinus is saying using a square rather than circle collision shape, using cast shape collision reduces this significantly but doesn't fix the issue fully. As result if one was to create a bouncing ball that goes down and bounces up on collision it would eventually start bounding other angle and at different speed despite no other forces being used.

What is worse documentation suggest that RidigBody2d should be exatly what we are supposed to use for simple games where we want ball to collide with some blocks.

@Calinou Calinou changed the title Incorrect bounce angle of RididBody2d Incorrect bounce angle of RididBody2D when using the Cast Ray Continuous Cd mode Jan 31, 2020
@Calinou Calinou changed the title Incorrect bounce angle of RididBody2D when using the Cast Ray Continuous Cd mode Incorrect bounce angle of RigidBody2D when using the Cast Ray Continuous Cd mode Jan 31, 2020
@jtaart
Copy link

jtaart commented Jan 31, 2020

The contact seems to be flipped. Don't exactly know whats going on with the function, but it seems a little off.

if (p_swap_result)
_contact_added_callback(contact_B, contact_A);
else
_contact_added_callback(contact_A, contact_B);

flipped gif
unflipped gif
temp fix gif

@madmiraal
Copy link
Contributor

This may be related to #28438. It appears to occur when colliding with the point between two CollisionShapes. Since it calculates the collisions separately, there is a collision with the corner of one shape i.e. a little bit of the edge between the shapes.

@Yolwoocle
Copy link

This still seems to happen in 4.2.1. Is there any plan for a fix? It's been 4 years.

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.

8 participants