How to Rotate a game object towards the mouse click

hi every body, i’ve been looking around on the forum and i’ve seen similar questions and unfortunatly i didn’t came to a solution; here is the thing :
i succeeded to shoot arrows to the position where the mouse clicked.
Now i want to rotate my bow towards that position : rotating it only around the Z axis.
every time i end up with my bow changing its position.
here is the my code :

var arrow : GameObject;
var bow : GameObject;

function Update () {
	if( Input.GetMouseButtonDown(0) ){//Mouse							

function ShootArrow(){		
		var mousePos : Vector3 = Camera.mainCamera.ScreenToWorldPoint(Input.mousePosition);//Mouse 			
		arrow.transform.position.Slerp(arrow.transform.position, mousePos,  Time.deltaTime)	;


thank you
PS : it’s a 2D game

The drawing was very helpful in understanding your problem. This looks like a 2D game. If so, attach this to your bow and set mousePos.z to the distance from your camera to your bow.

function Update () {
    var mousePos = Input.mousePosition;
    mousePos.z = 10.0f; //The distance from the camera to the player object
    var lookPos : Vector3 = Camera.main.ScreenToWorldPoint(mousePos);
    lookPos = lookPos - transform.position;
    var angle : float = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;
    transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

This aligns it continually, not on a click.

This is probably what I would use:

thank you justin !! i already tried the LookAt function, but my bow is moving !! it perhaps looks to the mouse position (i counldn’t tell) but doesn’t stay at its position.
i hope it’s clear, if not i would post an image to explain it (i think the concept of the bow and arrow is a classic though :slight_smile: )