STI & physics - body & shape offset

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
ClaudeM
Prole
Posts: 30
Joined: Sat Oct 16, 2021 6:27 pm

STI & physics - body & shape offset

Post 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 5266 times
Any help is appreciated.

Thank you.
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: STI & physics - body & shape offset

Post 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.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: STI & physics - body & shape offset

Post 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.
Attachments
bulldozer.png
bulldozer.png (153.12 KiB) Viewed 5184 times
User avatar
ClaudeM
Prole
Posts: 30
Joined: Sat Oct 16, 2021 6:27 pm

Re: STI & physics - body & shape offset

Post by ClaudeM »

Excellent! Using the current STI master changes the behaviour. I will pursue this over at STI. Thank you.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Semrush [Bot] and 21 guests