# Rotate plane on a pivot to the mouse position (in 2D)

Hello unity community again!

I have a more rudimentary question now, however, I am struggling to find a solution.

I have a 2D player sprite on a plane, all rigged for sprite animation and movement. However, I would like to add a black coloured plane just behind that will simulate his other hand. This hand is meant to follow the mouse.

However, No matter what script or function i use, his arm never follow the mouse properly and often disort it (as i have it in another object ot get a new pivot.)

Is there any way to fix it?

``````//var tmpPos : Vector3 = Camera.main.ScreenToWorldPoint (Vector3 (Input.mousePosition.x,Input.mousePosition.y,0));

//MousePositionWorld = Vector3(-tmpPos.x,-tmpPos.y, transform.position.z);

//Arm.rotation = Quaternion.FromToRotation(transform.position, -MousePositionWorld);

//Arm.LookAt(MousePositionWorld, Vector3.up);

var mousePos = Input.mousePosition;

// get the mid-point distance between camera and object

mousePos.z = transform.position.z;//Vector3.Distance(Camera.main.transform.position, transform.position)/2;

// look at this world point

Arm.LookAt(Camera.main.ScreenToWorldPoint(mousePos));
``````

Here is a picture to help you understand on what exactly I want to do.

Thank you for your help in advance, hope it is resolved soon. -Lachee

Arm.rotation = Quaternion.FromToRotation(transform.position, -MousePositionWorld);

this isn’t right

FromToRotation (FromDirection, ToDirection)

DIRECTION

not position.

use transform.RotateAround(point, axis,angle)

for this next part

point = point as which the arm connects with the body, the pivot point. You’ll have to pick a point

A = whatever direction your starting from or in this case
A = point on the plane you want to end up where the mouse is - point

B = where you want to end up or in this case
B = mouseposition - point

axis = vector3.cross(A, B);

angle = (i think) mathf.atan2(Magnitude(axis), vector3.dot(A, B));

Best of luck.