hi! help with converting in screen coords. I made crosshair following where is muzzle of tank aims.
But i can’t convert world coord in screen rightly.
if(Physics.Raycast(firePoint.position, firePoint.TransformDirection(Vector3.left), out hit))
{
Debug.DrawLine(firePoint.position,hit.point,Color.red);
// Vector 3 of hit.gameobject
pointCursor = Camera.main.WorldToScreenPoint(hit.transform.position);
}
void OnGUI()
{
Vector2 vector2 = GUIUtility.ScreenToGUIPoint(new Vector2(pointCursor.x, pointCursor.y));
Rect labelRect = new Rect();
labelRect.x = vector2.x;
labelRect.y = vector2.y;
labelRect.width = cursorTexture.width;
labelRect.height = cursorTexture.height;
GUI.DrawTexture(labelRect,cursorTexture);
}