Author Topic: Grids2D - Line of Sight and CellCross Costs  (Read 1013 times)

iceyp

  • Newbie
  • *
  • Posts: 24
    • View Profile
Grids2D - Line of Sight and CellCross Costs
« on: February 03, 2019, 04:33:28 AM »
Hi.

I may have misunderstood this (as usual) but is it possible for the LOS method to consider cell side crossing costs? For example in Demo13, could it be possible for the 'barrier' to block LOS to the cells beyond. In my particular case a simple example would be two units on opposite sides of a door and the door is along the side that is shared by the two cells (BOX topology in this case). The two units should not have LOS to each other.

Regards.
Ian.
« Last Edit: February 04, 2019, 09:53:39 AM by Kronnect »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4843
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #1 on: February 03, 2019, 05:43:11 AM »
Hi Ian,

Currently the LOS method use the "canCross" cell property. It does not take into account any crossing cost.
What should do a LOS method that takes into account crossing costs? Would it just stop if there's some side with a cost assigned?

iceyp

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #2 on: February 03, 2019, 07:48:28 AM »
Hi.

Thanks for getting back so quickly. I think it would suit my needs to just stop when it hits any cell side cost which is greater than 0 (I assume it can still return the cell indices up to that point).

Kind Regards.
Ian.

iceyp

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #3 on: February 04, 2019, 12:08:32 AM »
Hi.

Had a bit of a think overnight and believe there is a better solution to this as I can think of a problem with just 'blocking' LOS with a cell side cost > 0 and it is to do with height.

If you could a image a square room (say 3x3) with a balcony along the top edge. The balcony cannot be accessed directly from the other 6 squares in the room, so you set the cell side costs between balcony row and next row to > 0 to prevent movement (like the barrier in Demo 13). However you can shoot at/from the balcony, so LOS is not blocked by the cell side costs.

I think a better solution to implement LOS across cell sides would be to have a blocksLOS bool[8] array like the costs single[8] array that dictates whether a cell side blocks LOS. Together these would handle movement and/or LOS.

What do you think?

Kind Regards.
Ian.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4843
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #4 on: February 04, 2019, 09:54:19 AM »
That would be a nice feature. Adding this to Feature Requests :)

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4843
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #5 on: February 04, 2019, 11:53:50 AM »
Added to latest beta. Check out demo scene 13. LOS now is blocked by the barriers.

iceyp

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #6 on: February 05, 2019, 12:31:47 AM »
Brilliant! Wonderful support as always, this will help me out enormously.

Many Thanks.
Ian.

iceyp

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #7 on: February 06, 2019, 06:21:14 AM »
Hi.

I've been playing around with the new LOS and all seems great apart from one example (again hopefully I haven't done something stupid!). In the attached images I shortened the barrier and then did LOS from the end squares (exhaustiveCheck=false). The picture on the right appears to be correct as centre to centre the blue square should be blocked whereas the picture on the left (the reverse of the first) the LOS has been drawn when I think it should be blocked like the first.

Kind Regards.
Ian.
« Last Edit: February 06, 2019, 06:23:01 AM by iceyp »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4843
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #8 on: February 06, 2019, 06:33:22 AM »
I'll check this later. Try increasing the value of lineResolution parameter.

iceyp

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #9 on: February 06, 2019, 07:37:50 AM »
Setting the lineResolution to any number greater than 2 does the trick. Thanks.

iceyp

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #10 on: February 08, 2019, 06:26:07 AM »
Sorry to be a pain but I think there is still a problem with Box topology LOS, specifically when blocking sides are set on the Right or Left sides.

If you modify Demo 13 like the attached picture to set blocksLOS=true on the right side of the three squares and play around with the LOS, you will see there are a number of instances when the LOS will get drawn like the picture. This can happen from either side of the barrier. Setting lineResolution did not help in this case.

Kind Regards.
Ian.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4843
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #11 on: February 08, 2019, 06:35:55 PM »
Check out the new beta.
Regards

iceyp

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #12 on: February 21, 2019, 01:29:44 AM »
Hi.

Have tested LOS extensively but still get occasional problem. Please see attached screenshots. I've set top and left side of a cell to block LOS and still get errors in LOS. The picture on left uses lineResolution=5 and has a problem with cells that are exactly diagonal. The right picture uses lineResolution=2 and has problems with cells that are exactly 1 to the left of the diagonal.

Kind Regards.
Ian

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4843
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #13 on: February 21, 2019, 03:08:16 AM »
I can't reproduce that issue, it works fine on my end. Any chance you're using an older version perhaps? Just check if you can update your Grids2D package to latest from the Asset Store.
If problem persists, can you share your Grid2D settings?
Thanks

iceyp

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Grids2D - Line of Sight and CellCross Costs
« Reply #14 on: February 21, 2019, 07:26:34 PM »
Hi.

I have the latest version (the ReadMe in the root directory shows Version 6.0).

All I did was change Demo13. The topology from Hex to Box in the editor and changed the barrier code to the attached (can't include the code in the post as it causes an error when I try to post):