Page 1 of 1

[SOLVED] Collision library does not detect character in corners

Posted: Sun Jan 12, 2020 7:07 pm
by Pixet Bits
I had not understood löve's own physics libraries well. So I decided to create my own. So far it worked relatively well, but when I paired it with a tilemap library (which creates a collider for each tile) the character started going through walls when falling over corners.
My project is attached below (the game starts at 3th room, skipping the start screen and other stuff).

* Libs\collision_lib.lua : file that creates platforms (collisors) and returns the nearest walls
* Libs\tilemaps_lib.lua : file that open the room level file (.txt) and creates the tiles and collisors
* Libs\transform_lib.lua : character class

* Use the arrows to move and X to jump

Not a big problem, but it bothers me a little to leave "holes" on the map. If anyone can help I would appreciate

Re: Collision library does not detect character in corners

Posted: Sun Jan 12, 2020 11:04 pm
by raidho36
Try inspecting other people's libraries, such as Bump. Then try making your own again, it'll be easy. Or, you can just use some existing library.

Re: Collision library does not detect character in corners

Posted: Mon Jan 13, 2020 1:21 pm
by Pixet Bits
I think I got it.

Code: Select all

-- Fix bug --
if vect.y > plats[l].fr_w and vect.y < plats[l].rf_w then
if vect.x > plats[l].lt_w and vect.x <= plats[l].rt_w - 4 then vect.x = plats[l].lt_w end
if vect.x < plats[l].rt_w and vect.x >= plats[l].lt_w + 4 then vect.x = plats[l].rt_w end
end
At least it worked in the parts where he crossed. I had to edit a part on the jumping command too.

Code: Select all

... and math.floor(self.cpos.y) ~= self.w_col.up then ...