Hi all,
I’ve written a script to generate an N sided regular polygon shape consisting of cubes.However I want to position the shape so that the camera is at its center point.
I was thinking that if I found a point that is the radius of the shape distant from the camera position along an angle of 360- interior angle/2 as the starting point of the shape generation that would work.
So for a 4 sided shape, the interior angle is 90 degrees between sides. So half that is 45degrees. So if i started generation at a point the radius distant from the camera position along the direction of -45 degrees that would ensure the camera is central.
I know how to find the radius and angle. But I cant seem to get the position right:
Quaternion theAngle = Quaternion.Euler(0, -angle/2, 0);
Vector3 tdirection = theAngle * Vector3.forward;
initPosition += tdirection * tunnelRadius;
initPosition is the position of the camera. Any ideas? Thanks.