Closed Crumbler closed 6 years ago
This looks like the "getting stuck" problem that happens when trying to slide a polygon shape over other polygon shapes. You can work around it via a few ways like the "ghost vertices" technique that I think is implemented in the VelcroPhysics ChainShape. Just make the ground (or a layer just above it) that you're trying to slide over out of the ChainShape.
Incidentally, if this is that problem, I've written up a technique that solves it for polygons. If people want to implement it within VelcroPhysics I'd be honored though I don't know for sure what kind of performance hit it'd have. The more eyes on it the better in any case I figure.
It is as @louis-langholtz says. You can use the extra vertices of ChainShape to link segments together to prevent this from happening.
I've found several possible solutions to my problem.
This was suggested by my friend. Have each multi-tile structure as 1 huge body(with hard-coded fixtures). This would make level editing a pain though.
From the iforce2d article - make the edges rounded, It doesn't solve the problem. The player just begins bumping over the ghost vertices.
CollinearSimplify - I found this while browsing the documentation on codeplex. FarseerPhysics has quite a few algorithms. I tried adding each tile as a rectangle.
Vertices ver = new Vertices(); ver.AddRange(PolygonTools.CreateRectangle(tempentity.GetGlobalBounds().Width / 90f, tempentity.GetGlobalBounds().Height / 90f)); ver = FarseerPhysics.Common.PolygonManipulation.SimplifyTools.CollinearSimplify(ver, 1f); BodyFactory.CreatePolygon(world, ver, 1f);
However, using this algorithm produces a huge collision box in the center of the level. Am I doing anything wrong?
Using a ChainShape. Unfortunately I lack the skill to code an algorithm that would find groups of tiles and combine them into a group with a ChainShape. My level is just a txt file with bytes(a tileset).
Maybe you can try to add a few rounded 'lengs' to your sprite.
|______________________________|
O O O O
will this work?
or add a OnSereration event to your tiles, and disable the Contact when the collision cause it to stuck.
@nkast This problem also occurs in the vertical direction.According to your approach,the"legs" must be changed to "tentacles":)
o| |o
o| |o
o|__________|o
o o o
I think this is what I'm going to do: Add each tile as 4 edges. Then remove overlapping edges and merge the ones that are connected by one point.
The problem is solved now. You can close the issue.
I'm coding a simple game with SFML.Net and I'm using Farseer Physics(from codeplex). The player is a rectangle with a fixed rotation. The level is just a bunch of tiles(which are static rectangles with a fixed rotation.). However, when the player is sliding across several tiles, he sometimes gets stuck on the corners of tiles that are close together. Here's a gif demonstrating the issue: https://imgur.com/a/LOp4W The character gets stuck on the corners. The scale is 90 pixels to 1 meter. Here is a download of my project(compiled): YetAnotherSFMLApp.zip Edit: I didn't have this issue when using Box2Dx.