- Home /
Question by
chalkesonali · Nov 22, 2014 at 08:05 PM ·
rotationspritelagmouseposition
Rotating sprite on mouse drag like clock hand.
i want to rotate a 2d sprite of a sword from 0 to -90 along the z axis on mouse drag just like a clock hand.
i have used the following code:
if (Input.GetMouseButton (0))
{
hitpoint=new Vector3(transform.position.x,transform.position.y,Mathf.Clamp(Input.mousePosition.y-Screen.height/2,-90,0));
transform.rotation=Quaternion.Euler(-hitpoint);
}
this rotates the sprite but the problem is mouse position lags while rotating.how can i rotate the sprite along the z axis so that the mouse position is always on the sprite.
screenshot (2).png
(8.8 kB)
Comment