As my trig was never on par with anything, and it's 2:35am, I've been having a little trouble figuring out how to detect if a point (unit) is within the cone of sight of another unit. I've been looking for a while for a decent tutorial on the subject but my efforts have proved to be fruitless.
I understand that to start I'll need:
Point of Unit 1 (X,Y,Z)
Facing angle of Unit 1
Facing angle offset of 45 degrees to the left and right of the facing angle.
Point of Unit 2 (X,Y,Z)
View Distance (circle radius)
On a 2D platform I believe the basic diagram would resemble the following:
But I can't for the life of me figure out how to connect everything, let alone convert detection to include the Z plane.
Would anyone be willing to share any knowledge on the issue?
I know its possible, someone else made a thread about it and then someone posted a demo video of them pulling it off...but they never actually showed us how its done. I also know ProzaicMuze posted that one of his weekly tutorials in I think week 7 was going to be how to make such a system but unfortunately I haven't seen it posted. :( I'm really interested in this concept as well.
So far what I figure is the best method to get at least that field of view started is you'd need to use positive and negative region space. Ie You make that circle a 'negative' region and then at a point on its perimeter directly ahead of the unit you'd center a positive space square region who's bottom left corner (in this case) is an intercept with the center of the circle/your unit in question. I know you can use attachments to get them stick them on a unit but that's as far as I ever got in the planning and never even tried creating those things in that configuration.
Basically, you should only have to check two things.
1. That the distance between the units does not exceed the max sight range.
2. That the "Lookers" facing angle does not differ too much from the angle between the two units.
I'm unsure if "Distance Between Points" takes the Z axis into account. Also, this obviously won't take into account any obstacles that may block true LOS, such as cliffs, trees, etc. I don't know what kind of map you're making, but the Z axis shouldn't matter that much anyway?
The Angle comparison should be simple enough, except that it has to know that 359 and 0 are only 1 degree apart. I kind of got bored with the problem before managing to figure out a smart way to detect these cases (sorry :-). Also, while testing, I found out that the units facing does not return 0 -> 359,9999... but -179,9999... -> 180. I haven't tested if "Angle Between Points" use the same range, but I would assume it does.
So, modify the angle check to detect the special cases and this should work.
As my trig was never on par with anything, and it's 2:35am, I've been having a little trouble figuring out how to detect if a point (unit) is within the cone of sight of another unit. I've been looking for a while for a decent tutorial on the subject but my efforts have proved to be fruitless.
I understand that to start I'll need:
On a 2D platform I believe the basic diagram would resemble the following:
But I can't for the life of me figure out how to connect everything, let alone convert detection to include the Z plane.
Would anyone be willing to share any knowledge on the issue?
Thanks :)
I hope you figure this out, because I need a system just like this for my next map.
I know its possible, someone else made a thread about it and then someone posted a demo video of them pulling it off...but they never actually showed us how its done. I also know ProzaicMuze posted that one of his weekly tutorials in I think week 7 was going to be how to make such a system but unfortunately I haven't seen it posted. :( I'm really interested in this concept as well.
So far what I figure is the best method to get at least that field of view started is you'd need to use positive and negative region space. Ie You make that circle a 'negative' region and then at a point on its perimeter directly ahead of the unit you'd center a positive space square region who's bottom left corner (in this case) is an intercept with the center of the circle/your unit in question. I know you can use attachments to get them stick them on a unit but that's as far as I ever got in the planning and never even tried creating those things in that configuration.
Basically, you should only have to check two things.
1. That the distance between the units does not exceed the max sight range.
2. That the "Lookers" facing angle does not differ too much from the angle between the two units.
I'm unsure if "Distance Between Points" takes the Z axis into account. Also, this obviously won't take into account any obstacles that may block true LOS, such as cliffs, trees, etc. I don't know what kind of map you're making, but the Z axis shouldn't matter that much anyway?
The Angle comparison should be simple enough, except that it has to know that 359 and 0 are only 1 degree apart. I kind of got bored with the problem before managing to figure out a smart way to detect these cases (sorry :-). Also, while testing, I found out that the units facing does not return 0 -> 359,9999... but -179,9999... -> 180. I haven't tested if "Angle Between Points" use the same range, but I would assume it does.
So, modify the angle check to detect the special cases and this should work.
@Berrala: Go
I wasn't aware of the Angle Between Points action! Thank you very much, Berrala! You've been an amazing help :)
And true about the Z axis. Can just do some traceline checking to detect any objects between the units as with cliffs.
Muchos <3