I want to create a crosshair that is not centered (60% down from the top). This seems to create a horrible new problem for me, I’m having trouble lining up my bullets with the crosshair. (I can implement the primitive solution of rotating my bulletSpawn until it looks right but I’d prefer to figure out a more technical approach.
The green line is a ray going through the crosshair’s position in the viewport.
The yellow line is a line that shoots from the crosshair outward parallel to the camera.
As you can see, neither of them line up perfectly with where the crosshair is pointing, interestingly it looks as if the crosshair is perfectly in the center of those 2. Does anyone have any knowledge of what is going on? =(
//Setting crosshair position:
position = new Rect( ( Screen.width - crosshairTexture.width ) *.5f, ( Screen.height - crosshairTexture.height ) *.6f,
crosshairTexture.width, crosshairTexture.height );
//Draw ray from camera through crosshair position:
Ray ray = Camera.main.ViewportPointToRay(new Vector3(.5f, .4f, 0));
Debug.DrawRay(ray.origin, ray.direction * 10, Color.green);