So, to quickly explain things:
I'm making a topdown kinda game, and there are solid tiles in it, of course. I'm using love.physics for collision detection/resolution.
I made an algorithmy thing that looks through the map and adds EdgeShapes (for the border of the solid tiles, i'm using EdgeShapes to avoid the "crack" collision problem).
The problem here is that my algorithmy thing isn't working right, and I have no idea why. To me, everything in it seems structurally sound. I can't tell why it wouldn't work.
the "algorithmy thing" in question is tile_alg_1/tile_alg_2 in walls.lua, by the way
Hi, i don't really know how to solve my problem
Hi, i don't really know how to solve my problem
- Attachments
-
- my thing.love
- (904.72 KiB) Downloaded 178 times
Re: Hi, i don't really know how to solve my problem
also forgot to mention exactly what my problem is, sorry. This should explain it
Re: Hi, i don't really know how to solve my problem
I recommend you make an "overkill" algorithm for this.
You add 4 edge shapes on every wall tile (even inside walls)
And after that a prune algorithm that removes unnecessary edges inside walls.
Sometimes it does not pay to be too smart with algorithms.
You add 4 edge shapes on every wall tile (even inside walls)
And after that a prune algorithm that removes unnecessary edges inside walls.
Sometimes it does not pay to be too smart with algorithms.
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Hi, i don't really know how to solve my problem
Using edgeshapes wouldn't be the best idea if I'm not mistaken if it has low DT or high speed I think. It would just jump right pass them. A polygon shape would be better. I think an algorithm to convert the tiles into polygons would be the best.
Re: Hi, i don't really know how to solve my problem
Tried that. It's alg_3 in my walls.lua. It encountered a similar problem.cohadar wrote:I recommend you make an "overkill" algorithm for this.
You add 4 edge shapes on every wall tile (even inside walls)
And after that a prune algorithm that removes unnecessary edges inside walls.
Sometimes it does not pay to be too smart with algorithms.
Tried that as well. I'm not using polygon shapes to avoid the "crack" collision problem. I remember reading something about ghost vertices, but just figured that EdgeShapes would be easier to deal with.bobbyjones wrote:Using edgeshapes wouldn't be the best idea if I'm not mistaken if it has low DT or high speed I think. It would just jump right pass them. A polygon shape would be better. I think an algorithm to convert the tiles into polygons would be the best.
Re: Hi, i don't really know how to solve my problem
I donwloaded the code and took a serious look.
ALL your algorithms are correct.
Your error is in iteration:
EDIT:
to be more precise your tile data is not correct.
previous algorithm for detecting which walls are invisible (tile == 0) is not correct.
ALL your algorithms are correct.
Your error is in iteration:
Code: Select all
for y_index,value in ipairs(map) do
for x_index,tile in ipairs(value) do
to be more precise your tile data is not correct.
previous algorithm for detecting which walls are invisible (tile == 0) is not correct.
Re: Hi, i don't really know how to solve my problem
There is something wrong with "map_generator.lua" You place non wall segments where there should have been a wall.
The .love I've added now draws red walls instead when map[x][y] == 1. I've also made the math.randomseed(10) so I don't have to go looking for broken wall segment each time.
The .love I've added now draws red walls instead when map[x][y] == 1. I've also made the math.randomseed(10) so I don't have to go looking for broken wall segment each time.
- Attachments
-
- my thing with walls.love
- (904.79 KiB) Downloaded 160 times
Artal, A .PSD loader: https://github.com/EvineDev/Artal
Re: Hi, i don't really know how to solve my problem
I apologize, I don't quite understand what you mean. What do you mean by tile data is not correct and detecting which walls are invisible (tile == 0) is not correct?cohadar wrote:I donwloaded the code and took a serious look.
ALL your algorithms are correct.
Your error is in iteration:EDIT:Code: Select all
for y_index,value in ipairs(map) do for x_index,tile in ipairs(value) do
to be more precise your tile data is not correct.
previous algorithm for detecting which walls are invisible (tile == 0) is not correct.
Re: Hi, i don't really know how to solve my problem
tile types in your map:
[0]walls that are inside/invisible
[1]walls visible by player (adjecent to floor tiles)
[2]floor tiles
To "see" what I mean, turn on alg_3 than instead of this:
do this:
take a look, and ask yourself, why is it working now?
[0]walls that are inside/invisible
[1]walls visible by player (adjecent to floor tiles)
[2]floor tiles
To "see" what I mean, turn on alg_3 than instead of this:
Code: Select all
function tile_alg_3(tile,objects,x_index,y_index)
if tile == 1 then
Code: Select all
function tile_alg_3(tile,objects,x_index,y_index)
if tile < 2 then
Re: Hi, i don't really know how to solve my problem
Haha. I can't believe it. I forgot about the 0's. Thank you so so much. I've been having this problem for so long.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests