So I have the following function to generate 3 vector points let creates a triangle:
private Vector3[] GetFieldOfViewPoint() {
float Range = 3f;
float Angle = 45;
Vector3 offset = new Vector3(0, Range, 0);
Quaternion rotation1 = Quaternion.Euler(0, 0, -Angle / 2);
Quaternion rotation2 = Quaternion.Euler(0, 0, Angle / 2);
return new Vector3[3] {
transform.position,
(rotation1 * offset) + transform.position,
(rotation2 * offset) + transform.position
};
}
The issue I am having is that when I increase the angle, the rang decrease which does make some sense to me.
For example, 45 angle:
135 angle:
The issue I need help with is how can I modify the calculation in order to keep the range line (the furtherest straight green line) consistent regardless of the angle (which will be capped at 170 degrees)?
I can get the range to move with the angle but doing random calculations but it is not consistent and just does not work (at least with the random number I have tried). I also thought about hypotenuse formula however I only know 1 sides length (which is the range).
Any help with this would be awesome.