• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[Solved]Line of sight for enemies with larger size

Sixtree

Member
Currently my game world consists of 32x32 tiles and the view is top-down. I have implemented pathfinding for enemy AI, but I only want AI to use it when they can't see the player. I have separate script that checks if a tilemap marked as collision is inbetween player and AI, but it only checks for one point (origin, which is bottom centre). Meaning if origin point can see the player but for example one of the edges is behind collision, AI gets stuck.
I thought I would check if points on the edges can see the player and then move on as needed. But I will have enemies sized 64x64 or 96x96 so those would have to have multiple checks along the edges to make sure they can follow the player. Is this kind of approach fine or is there a better way to do this?
 

Sixtree

Member
32x32 would be the smallest I want, I don't know if I need to check all four corners, I thought checking points along the bottom edge would do just fine
 

Nidoking

Member
I thought you said the problem was that parts of the sprite you're not checking are intersecting with obstacles. What if only a top corner clips the obstacle? You need all four corners at a minimum. Then you'd probably want to check at 32-pixel intervals if that's the size of your obstacles.
 
Top