FarseerPhysics Tilemap

So to test out the theory of having at least a 512x512 tile map in farseer, I decided to not waste time creating the tilemap just yet; instead create multiple, static bodies, but even having a 100x100 static objects, took super long to init them and super long to update(I would be lucky if I got 1 frame every 5 seconds). So what would be a reasonable way to fix this?

The only idea I’ve come up with is creating a independent tilemap collision system and interfering with the objects, the problem is however, if I do this the gravity will continue to speed up as it “falls” to the ground.

It is best to create shapes that best fit the collidable areas. This will minimize the number of objects the physics has to deal with. I used Farseer for the 2D collision in TY the Tasmanian Tiger 4. For this particular part of the level

there are only four physics objects for the terrain; two poly shapes (the yellow shaded areas) and two poly lines (the orange lines) (drawn really badly because I’m using Gimp on a Linux laptop)

The same principle applies to collision for a tilemap based game. Combine neighbouring shapes into one larger shape. If you have twenty tiles that make an L shape, use one L-shaped physics object.

I ended up just having a another image for the “colliders” and used farseers polygon tools to convert it into a body.

Thanks :slight_smile: and beautiful game you have there, gonna buy it on steam actually once I can get paid.

https://www.youtube.com/watch?v=peZk3rmAwF4 in this video you see this pretty much happening without the fancy graphics, but on slopes you notice the character goes up in the air for a little bit(not as apparent in the video but still visible) how can I fix this? I tried playing with friction on both objects.

Using a physics engine for a platformer is an all around bad idea. You have to fight the physics system to get it to do what you want because what you want to do is not physically possible. See this article for just a few of the reasons why.

When you make a platformer if you want it to actually have a good feel you have to do it yourself. Don’t pass of the main interaction of your game to a physics system. Take control of it and make movement feel exactly how you want it to. If you need a base for a tile map collision system here is a fully function class that handles slopes and everything. One public method: move( Vector2 ). You will just need to change it a bit so that it knows about your specific TileMap class.