-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Collision result prioritizes nearest point rather than the length of the collided size #46746
Comments
In a scenario like this where the kinematic body starts stuck inside another shape, it gets unstuck by finding the shortest path to be pushed out, so that's the expected behavior with a short segment shape and a long object. Could you describe a bit more in context what you're trying to achieve in your game? That might help finding the right workaround (or bug to fix). One way to solve this problem could be to use |
@hydescarf Sorry for the delayed answer. It's nice to know you already have some workarounds! I think this use case makes sense, it's just not easy to make it work in a generic collision algorithm. And in a different scenario, someone might need segments to push objects from their ending points. I can see how it could be useful to use segments this way though, and possibly polygon shapes as well. Maybe there could be an option for segments or a separate shape that would push objects only along their normal like a line does. That would require some more investigation to figure out how to implement it and a proper proposal from me or another contributor. In the meantime the best option is to use a custom logic in script like you did in your workarounds. |
Yeah, I figured as much. I think there's two ways of making this works,
Thank you for your feedback. In any case, I'll continue using my workaround for now since my collision is somewhat half-customized anyway. (Using |
Godot version:
3.2.3
OS/device including version:
Windows 10
Issue description:
I believe this isn't technically a bug, and it's intended. When the collider collides, it finds the nearest place to get off the collided object.
However, in my case, I have a code where the player
RayCast2D
can summon an object (on the arrowhead). If the summoned object is bounded to touch a wall, it should bounced behind the wall.This is what I expected to have:
Straight vertical line on the left as wall, rectangle box as summoned object, and arrow as player.
Instead, the summoned object bounced below the wall's end point (I used
SegmentLine2D
but it also happens inRectangleShape2D
).Doesn't matter if I used
move_and_collide()
, ormove_and_slide(velocity, Vector2(1,0))
.On the other hand, if the collider size is smaller than maybe, the wall length?, it bounced back normally
or if the wall length is longer and the collider is around the center point, it also bounced back normally.
In this case, I was wondering, is the collision depending on the center point instead of overall shape? Because it will still happen if you summon the collider around the bottom of the wall regardless of the wall length.
My question is:
Should the collision result be based on the length of the collided surface instead of the nearest end point? This one is especially crucial for line-based CollisionShape like
SegmentLine2D
, because we don't need that at all, but only the length between two points.Minimal reproduction project:
bug report.zip
Note that in the file, there is a
Raycast2D
to determine the summoning point, when it touches the wall, the to-be-summoned object will automatically bounce back, that works well and it's not related.The text was updated successfully, but these errors were encountered: