how to create a old (2D style) fps cursor

i want to create a mouse cursor that can move on screen and shoot bullets with it. i want something like classic nes 2d fps controls. i don't want and can not use OnMouseDown. how can i detect what object is under the mouse with raycasting? i thought i should use the field of view and position of the mouse and it's difference from center to calculate the angle of the ray but i could not make any working component. i just need to know what is under the mouse cursor and then shoot something toward it.

Camera.ScreenPointToRay is your friend in this case http://unity3d.com/support/documentation/ScriptReference/Camera.ScreenPointToRay.html

Remember that unlike UnityGUI, the screen coordinates are from bottom left, in pixels.

Trying to work out what you mean here... So, for example you would move your cursor around the screen and over a target, then press space to fire a bullet from your gun ( positioned elsewhere on the screen? ) to the target under your cursor?

So you'd cast a ray from current mouse position to detect if anything is there, then work out the angle from your gun to the target, then fire along that angle. Something like the following...

var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition); //fire a ray from current mouse pos
var hit: RaycastHit; 

if (Physics.Raycast(ray, hit)) { //if the ray hits something...
            if (hit.transform == yourTarget){  //if that something is what you want to target
                var targetAngle = Vector3.Angle(Vector3.up, yourTarget.transform.position - yourGun.transform.position);  //work out the angle between your gun and the target
                //then rotate your gun to face target based on the above angle and instantiate your projectile
            }
}

this is only a really rough outline of what might work, I don't have time to test sorry

to find the direction without the ray, you can use a number of methods:

first, find the screen co-ordinates using Camera.ScreenToViewportPoint ( http://unity3d.com/support/documentation/ScriptReference/Camera.ScreenToViewportPoint.html ) . This will give you values from 0 - 1, bottom left to top right.

Then calculate the angular deviation from the center of the screen using the Field of View and the aspect ratio. For the y direction the calculation looks like:

deviationy = (ViewportPt.y - 0.5) * fovy
deviationx = (ViewportPt.x - 0.5) * fovy * aspect

endpoint = Cam.forward * farClip + Cam.right * cos(deviationx) + Cam.up * cos(deviationy)

rayDirection = (endpoint - camera.pos).magnitude