четверг, 19 апреля 2012 г.

Прицел

Как получить объект в прицеле


Ray ray = camera.ScreenPointToRay(new Vector3(camera.GetScreenWidth()/2  ,camera.GetScreenHeight()/2, 0.0f));
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
Vector3 meshPos = camera.WorldToScreenPoint (hit.transform.position);
GUI.DrawTexture(new Rect(meshPos.x-25 ,camera.GetScreenHeight()-meshPos.y-25 ,50,50), texture, ScaleMode.ScaleToFit, true);
}

Комментариев нет:

Отправить комментарий