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

Bullet behaviour: sprites travelling parallel and adjacent to solid objects rebound incorrectly #622

Closed
jakemay74 opened this issue Jul 15, 2017 · 3 comments
Assignees
Labels

Comments

@jakemay74
Copy link

Problem description

Small rectangular sprites with the bullet behaviour travelling parallel to solid objects within <5 of pixels are not deflected 180 degrees when colliding with a perpendicular solid object.

Attach a .c3p

https://www.dropbox.com/s/dia9gfn1hm68lna/ballcollision.c3p?dl=0

Steps to reproduce

  1. Open ballcollision.c3p
  2. Confirm angles of sprite and borders to be orthogonal and there to be a gap between the side borders and adjacent sprites.
  3. Preview layout in debug.
  4. Observe the path of the sprite objects and check angle in debug.

Observed result

The left and right sprites do not rebound 180 degrees to their angle of motion.

Expected result

The sprites should rebound 180 degrees regardless of proximity to the side borders if not colliding with them.

Affected browsers

  • Chrome: yes

System details

If you see a crash report dialog, please copy and paste it to where it says "PASTE HERE" below. Otherwise please go to Menu -> About -> Platform information and paste that information there instead.

View details

PASTE HERE

@AshleyScirra AshleyScirra self-assigned this Jul 17, 2017
@AshleyScirra
Copy link
Member

When calculating a bounce, Construct has to calculate the normal of the bounced surface from an arbitrary collection of objects. This is quite a difficult thing to accomplish, and it uses an approximation algorithm which looks at nearby objects. This means the objects very close to the edges take in to account the side barriers when computing the normal of the collision, which causes them to bounce at a different angle. This is the kind of thing which is far too troublesome to ever change, since likely hundreds of existing Construct games already depend on the bounce calculation working the way it does. Even improving the accuracy could cause some other games to start misbehaving. So I don't think it's worth fixing this; it's a minor quirk of the bounce algorithm, most people seem happy with it the way it is, and backwards-incompatible changes can cause borderline revolt amongst users, so closing as won't fix.

@jakemay74
Copy link
Author

I appreciate the explanation for why this is a no fix; that said, I could understand if we're talking about a pixel or two gap resulting in a the angle being off by a few degrees, but there's a clear 4px gap between the bullet and the border resulting in a 45 degree deviation from the expected angle, off flat orthogonal surfaces, which isn't exactly a minor quirk.

I recognise that the hope is many users will import their existing C2 projects over, but doesn't C3 being in beta offer an opportunity to clear up these sort of issues with the behaviours and get them working as expected?

@AshleyScirra
Copy link
Member

IIRC the tolerance is based on the distance it moved last tick, so actually depends on the speed. This is because it only has two data points when calculating a bounce angle - a known colliding point and a known not colliding point, and it works from there. So the tolerance is probably 10px or so.

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

No branches or pull requests

2 participants