### Box physics problems

Posted:

**20 Jun 2019, 09:19**The box physics are still pretty weird in 0.5.1 Alpha:

1) If a box is on a moving block and is pushed right into another block, the box will either just move through these solid blocks like a ghost or it will fall down, through solid blocks. You can force boxes to go through walls this way.

2) The Stonehenge Bug: If you build boxes like Stonehenge and push first the left box a bit, then the right box, the upper box behaves differently. One time, it stands still, the other time, it moves with the box.

Like so:

3) If you build two conveyor belts horizontally next to each other, the left one with speed -5, the right one with speed 5, and put a 2×1 box right on the middle, the box will move right. Set the speed of the left conveyor belt to -20, the box will still move to the right. The “force” of the left conveyor belt is completely ignored

Suggestions for fixes (Note none of this has been tested):

1) Crush and destroy boxes when they end up in anything solid, like players

2) The upper box should not move in both cases since it still has the other box to rest on

3) Basically, take the average speed of all conveyor belts on which the box is on. Set X=0 and N=0. For each pixel of the bottom of a box, check if it's directly on a conveyor belt. If yes, add the speed of that pixel to X and add 1 to N. The final speed of the box is X divided by N. To prevent the speed becoming 0 due to rounding errors, force the minimum speed to be 1 (or -1, depending on direction) if X does not equal 0.

Example: For the box in the example above in 3) (speed -5 left, speed +5 right), this would be a box speed of exactly 0 because (50 pixels*-5 + 50 pixels *5) / 100 pixels = 0

Example 2: With the conveyor belt speeds -20 left and +5 right, the calculation will be (50 pixels * -20 + 50 pixels * 5) / 100 = -7.5

Please post other problems with box physics here.

1) If a box is on a moving block and is pushed right into another block, the box will either just move through these solid blocks like a ghost or it will fall down, through solid blocks. You can force boxes to go through walls this way.

2) The Stonehenge Bug: If you build boxes like Stonehenge and push first the left box a bit, then the right box, the upper box behaves differently. One time, it stands still, the other time, it moves with the box.

Like so:

- {l Code}: {l Select All Code}
`AAAAAAA`

B C

B C

B C

(3 boxes total, each letter is a box)

3) If you build two conveyor belts horizontally next to each other, the left one with speed -5, the right one with speed 5, and put a 2×1 box right on the middle, the box will move right. Set the speed of the left conveyor belt to -20, the box will still move to the right. The “force” of the left conveyor belt is completely ignored

Suggestions for fixes (Note none of this has been tested):

1) Crush and destroy boxes when they end up in anything solid, like players

2) The upper box should not move in both cases since it still has the other box to rest on

3) Basically, take the average speed of all conveyor belts on which the box is on. Set X=0 and N=0. For each pixel of the bottom of a box, check if it's directly on a conveyor belt. If yes, add the speed of that pixel to X and add 1 to N. The final speed of the box is X divided by N. To prevent the speed becoming 0 due to rounding errors, force the minimum speed to be 1 (or -1, depending on direction) if X does not equal 0.

Example: For the box in the example above in 3) (speed -5 left, speed +5 right), this would be a box speed of exactly 0 because (50 pixels*-5 + 50 pixels *5) / 100 pixels = 0

Example 2: With the conveyor belt speeds -20 left and +5 right, the calculation will be (50 pixels * -20 + 50 pixels * 5) / 100 = -7.5

Please post other problems with box physics here.