Platform with multiples blocks

Topics: Developer Forum, User Forum
Mar 14, 2012 at 7:49 PM
Edited Mar 14, 2012 at 8:27 PM


I'm currently working on a platform game in the kind of Terraria and I have a problem.

Here is a screenshot from the game :

You can we have several blocks put close to each others. The problem is that when you walk on the right or on the left, you sometimes (often actually) get stuck by one of those blocks without any reason...

The blocks are spawned by two for loops :

I have only removed some custom function that doesn't read or modify the position of the body.

// the const BLOCK_OFFSET doesn't change anything to the bug
float size = GRID_SIZE - BLOCK_OFFSET;

Body _baseBody = BodyFactory.CreateRectangle(World, size, size, 6f, BlockTypes.Ground);

for (float y = 0; y < 21; y += GRID_SIZE)
    for (float x = -40; x < 41; x += GRID_SIZE)
        Body _terrain = _baseBody.DeepClone();
        _terrain.Position = new Vector2(x, y);

I don't know if it's from my code or from the engine...



Edit : the picture wasn't uploading :(

Mar 16, 2012 at 5:25 PM

known bug that probably won't be fixed for quite a while. you'll have to merge nearby blocks into a single big one.

Mar 16, 2012 at 5:52 PM

That's what I was feared... The problem is that we need destruction for the game... Merging the blocks each time will need a voracious algorithm (generated terrain ><)...