So I have a couple of cells
How would I get nearest 4 cells (green ones) near one (red)
I know I could use region3 to get all 8 cells near, but I need only 4
So I have a couple of cells
How would I get nearest 4 cells (green ones) near one (red)
I know I could use region3 to get all 8 cells near, but I need only 4
You could filter the result from the region3 stuff to remove any that are farther away than a single orthogonal step. Diagonal steps would be sqrt(2) * cellSize
I think.
So I compare magnitude? Which one with what? Basically if I try doing like u said, the diagonal step’s magnitude would be bigger than any other one in my results so I wouldn’t get any results at all
Could you not just simply
cell1 = {cellx - 1, celly}
cell2 = {cellx + 1, celly}
cell3 = {cellx, celly - 1}
cell4 = {cellx, celly + 1}
And then store a list of valid cells and check if certain ones aren’t in the map and remove them.
So I would just compare positions?
No, I mean you would know the positions of each cell already beacause they are always right next to your cell.
If what you meant was to check if they exist, then yes. The ropmost red cell has adjacent cells outside the “map” so you’ll need to make sure they all exist.
You could alternatively use a raycast or use a list with all the cells in it and use the list to find the nearest cells. Or loop through all the cells and find the closest ones if that’s what you want.
Thanks man! I needed the model though, not just the position. So what I did is just comparing the position I needed (from your method) with the ceratin part’s position in the cell model. If positions are same, that’s the cell model I need
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.