I am sure there is a simple solution to this that happens to elude me at the moment.
I co-working on a game and have an issue with non-player characters that navigate the platform based levels. These are controlled directly based on position and several detection areas.
The Enemies are allowed to rotate to a degree as the platforms are not at right angles and involve slopes and non-flat areas.
As an enemy moves (left for example) I use a line of sight check along the travelling side to look for a platform and decide if it should turn around or jump the blockage. This has issues because I have to nip one end of the check within the enemy area to allow the line of sight to work (I understand it will not detect unless it starts within a body). This causes errors in the detection where a detection is not made because of this nipping of the LOS check.
What I 'really' need is a rotated AABB check to grab a block area that covers the height of the enemy and a small detection width.
The picture illustrates the area I need to check (amongst others) based on the rotation of the enemy. As I say, it almost works using LOS. I originally kept the detection to a straight AABB check lifted based on the angle of rotation, but this (though better) also gave issues.
Any help or suggestions would be great.
(Also is a picture of how I was originally doing it with 3 point checks on the areas needed, this worked ok when the check areas where as large as half the distance between, but still not a great solution)
I co-working on a game and have an issue with non-player characters that navigate the platform based levels. These are controlled directly based on position and several detection areas.
The Enemies are allowed to rotate to a degree as the platforms are not at right angles and involve slopes and non-flat areas.
As an enemy moves (left for example) I use a line of sight check along the travelling side to look for a platform and decide if it should turn around or jump the blockage. This has issues because I have to nip one end of the check within the enemy area to allow the line of sight to work (I understand it will not detect unless it starts within a body). This causes errors in the detection where a detection is not made because of this nipping of the LOS check.
What I 'really' need is a rotated AABB check to grab a block area that covers the height of the enemy and a small detection width.
The picture illustrates the area I need to check (amongst others) based on the rotation of the enemy. As I say, it almost works using LOS. I originally kept the detection to a straight AABB check lifted based on the angle of rotation, but this (though better) also gave issues.
Any help or suggestions would be great.
(Also is a picture of how I was originally doing it with 3 point checks on the areas needed, this worked ok when the check areas where as large as half the distance between, but still not a great solution)