Getting gun to look at mouse-point --> 2D

Hi,

As the title suggests, I am making a side-scrolling shooter game. The player aims with their mouse. I want the gun of the player to look as if it’s aiming where the mouse is aiming.

My current set-up is 2D planes with textures on them, and an orthographic camera. This successfully simulates the 2D effect I want to get.

I have tried to do:
transform.Lookat(Input.mousePosition) but this does not aim the gun at the mouse position (possibly because it uses a 3D Vector?).

Can anybody provide me with a solution to this problem?

Thanks,
Rich B

I am going to guess:

var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
transform.Lookat(ray.GetPoint (cameraDistance));

where cameraDistance is the distance from the camera to the plane where your are aiming.

you should also look at David Lancaster’s tutorial for this type of game (EVAC-CITY) here. He does the aiming differently there:
http://www.unitytutorials.com/document/298/how-to-make-a-game-similar-to-evac-city-in-unity3d