[SOLVED] Collision library does not detect character in corners

Show off your games, demos and other (playable) creations.
Post Reply
User avatar
Pixet Bits
Prole
Posts: 3
Joined: Fri Apr 26, 2019 6:29 pm

[SOLVED] Collision library does not detect character in corners

Post by Pixet Bits » Sun Jan 12, 2020 7:07 pm

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
Attachments
Eternity.love
The project file
(30.82 KiB) Downloaded 24 times
Last edited by Pixet Bits on Mon Jan 13, 2020 1:25 pm, edited 1 time in total.

User avatar
raidho36
Party member
Posts: 2055
Joined: Mon Jun 17, 2013 12:00 pm

Re: Collision library does not detect character in corners

Post by raidho36 » Sun Jan 12, 2020 11:04 pm

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.

User avatar
Pixet Bits
Prole
Posts: 3
Joined: Fri Apr 26, 2019 6:29 pm

Re: Collision library does not detect character in corners

Post by Pixet Bits » Mon Jan 13, 2020 1:21 pm

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 ...

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests