Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm having a problem with the Farseer Physics Engine, where in a tiled environment, my object will at times interact with corners of others objects, even if they align perfectly.

Tiling Physics using Farseer

I've read about people suggesting that you calculate and create one larger object, using Marching Squares or something similar. This is not an option however, as I'd like each tile to have different physical qualities, like different friction and restitution.

My question is, what exactly is causing it, is it float precision issues or something else? And is there a way to fix it, without breaking the whole physics engine?

share|improve this question
    
I wonder if you could simply expand the collision boxes by one pixel, so they overlap a bit. It may see the surface as more connected perhaps. –  Doug.McFarlane Aug 25 '11 at 19:02
    
@Doug: I just tested that, and it didn't make any difference. –  William 'MindWorX' Mariager Aug 25 '11 at 21:21
    
Are the ground tiles static bodies? –  bummzack Aug 26 '11 at 6:19
    
@bummzack: Yes they are. –  William 'MindWorX' Mariager Aug 26 '11 at 13:57
    
I am having the exact same issue. I get the "bouncing" effect when my movable object is a rectangle or a circle. I also cannot convert multiple squares into one large rectangle because I want the player to have the ability to "remove" individual tiles in certain situations. –  user9534 Aug 28 '11 at 5:48

3 Answers 3

up vote 4 down vote accepted

Farseer uses an iterative solver, so when your wheel starts colliding with another rectangle at high velocity, from time to time you'll see bumps since it's a "perfect align" to us, not to a physics simulation, with iterations things like these will never be "pixel-perfect".

You will have to convert rectangles to Edge/Loop shapes and then model different physical qualities with hacks like creating artificial tile bounds and then changing properties when character enters a bounding box, but not every physical quality can be emulated that way.

Sooner or later you'll end up writing your own tile-based physics instead of Farseer. If your game doesn't have lots of complex physics puzzles, it will be simpler to abandon Farseer completely and roll your own tile-based physics.

share|improve this answer
    
I actually have started coding my own physics engine, specifically for this tiling engine, since it doesn't seem like there's any elegant solutions. –  William 'MindWorX' Mariager Aug 28 '11 at 14:26
    
I decided to mark this the answer, as there doesn't seem to be any simple solution, and you'll be better off coding your own solution. Or accept that you can't have different physics and use Marching Squares to make larger bodies. –  William 'MindWorX' Mariager Aug 28 '11 at 15:19

you can optimize your collisions shapes, this scene can be done with only four rectangles.

you can join correlative boxes to make one bigger.

this video shows it http://www.youtube.com/watch?v=eyhGckHgkkE

when it is adding boxes you can see a light blue rectangle with the optimized shape.

share|improve this answer
1  
As I said in the third paragraph, turning a group of objects into a larger object is not an option, as I'd lose individual properties. –  William 'MindWorX' Mariager Aug 25 '11 at 21:57
    
you can group them by their phisycal properties too. i think it's not very usual to have a lot of different physical blocks together. –  Blau Aug 26 '11 at 6:19
    
Grouping them by physical qualities would give me the same problem if the terrain changes a lot on a stretch. It may be unusual, but nonetheless it's what I need. –  William 'MindWorX' Mariager Aug 26 '11 at 13:58

Hmm... I suspect it might have something to do with your circle and not the tiles beneath it. Try making the ground using a single hull and see if you get the same results. If not, it's the tiles like you suspect. If so, your circle isn't as round as you might think it is.

share|improve this answer
    
I did test that. Using one big rectangle there's no issues. –  William 'MindWorX' Mariager Aug 26 '11 at 0:36
    
k, Tiles are the issue then –  John McDonald Aug 26 '11 at 0:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.