STI & physics - body & shape offset
Posted: 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. 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.
Any help is appreciated.
Thank you.
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.
Any help is appreciated.
Thank you.