Page 1 of 1

STI & physics - body & shape offset

Posted: Sat Oct 23, 2021 1:34 am
by ClaudeM
Hi,

This is my first real game in LÖVE2D. I am amazed at how far I have gotten. I have been stuck for several days and need help. If I do not express myself clearly, ask for clarification.I will try to improve. English is not my mother tongue.

The game loads a map made with Tiled and uses STI with Box2D. The tiles, objects (the rocks), and player (bulldozer) all display correctly. The sketchy library displays the collision "boxes". There are two problems.
1) All the collision boxes for the rocks are all in the centre of the window.
2) The bulldozer collision box is offset by half a window.

The bulldozer moves as it should and its collision box moves with it (maintaining a fixed offset). The collision boxes collide properly - rock and bulldozer.

I have been searching with Google, reading forum posts, and looking at example code. I am missing something.

I tried adding an offset to the bulldozer rectangle by calling love.physics.newRectangleShape with dozer.x, dozer.y, dozer.width, dozer.height, and point-right (angle). It generated an "interesting" error: "Box2D assertion failed: m_I > 0.0f". I went back to the simple newRectangle call.

Here is a screen capture image taken after moving the bulldozer.
bulldozer-collision-boxes-in-the-wrong-place-20211022.png
bulldozer-collision-boxes-in-the-wrong-place-20211022.png (414.91 KiB) Viewed 5857 times
Any help is appreciated.

Thank you.

Re: STI & physics - body & shape offset

Posted: Sun Oct 24, 2021 2:30 am
by darkfrei
ClaudeM wrote: Sat Oct 23, 2021 1:34 am Hi,

This is my first real game in LÖVE2D. I am amazed at how far I have gotten. I have been stuck for several days and need help.
Please attach as minimal as possible game version with this bug. Less code makes the bugfixing much faster.

Re: STI & physics - body & shape offset

Posted: Sun Oct 24, 2021 11:40 am
by pgimeno
I've now downloaded your .love file and checked. This, and your other thread, is something you should probably ask the creators of STI, here: https://love2d.org/forums/viewtopic.php?f=5&t=76983 because it seems to be related to using STI itself.

For example, I replaced your STI version with the latest one from GitHub, and that caused a different result. The lines are rock-shaped and get distributed along the left side of the screen.

I suspect it has to do with your physics shape problems.

Edit: Oops, meant to post this in the other thread.

Re: STI & physics - body & shape offset

Posted: Sat Nov 13, 2021 9:07 pm
by ClaudeM
Excellent! Using the current STI master changes the behaviour. I will pursue this over at STI. Thank you.