I am using this tutorial (https://www.youtube.com/watch?v=vQ1UGbUlzH4&t=1273s) for Field of View implementation, but I'm having an issue. Once I come to a door that is closed, and try to "move" into it, I instead use the turn to open the door, changing the tile using
map.setcellv(herotile,opendoortile)
but when I do, my LOS calculation goes haywire for a turn, showing me a ton of empty walls I shouldn't be able to see. Once I move again, it is fixed. This happens if I change it to any tile id, regardless on whether or not the new tile id is colideable or not. It does NOT howeever happen if I set the tile to the same tileid, so setcellv itself is not the issue. Any ideas f what might be happening? Here is my calc_los code:
func calc_los():
#get field of view tilemap reference
var fov_tiles:TileMap=self.map.get_parent().get_node("fov")
#set all cells to black
for tile in self.map.get_used_cells():
fov_tiles.set_cellv(tile,0)
#capture phsyics state for collisions
var space_state=get_world_2d().direct_space_state
for tile in self.map.get_used_cells():
#this gets the nearest corner for testing
var x_dir=1 if tile.x<self.tile.x else -1
var y_dir=1 if tile.y<self.tile.y else -1
var test_point=tile_to_px_center(tile.x,tile.y)+Vector2(x_dir,y_dir)*self.map.cell_size/2
#var test_point=tile_to_px_center(tile.x,tile.y)
var occlusion=space_state.intersect_ray(tile_to_px_center(self.tile.x,self.tile.y),test_point)
#if there is no occlusion
if !occlusion or (occlusion.position-test_point).length()<1:
fov_tiles.set_cellv(tile,-1)
Here is a visual of what I am experiencing, so you can see the craziness in the second image:
https://imgur.com/a/SwNNkvt
Thanks for any help!