Question by
KraykonDev · Jan 31, 2016 at 11:05 AM ·
rotation360-degrees
Object rotate 360 but it should not
hi, i got a script that is attached to an arm that is a child of the player. The script work but it rotates 360 degrees i want it to just rotate from the 9-333 on the z-rotation please help me! Here is the script i am using:
public int rotationOffset = 90;
void Update () {
Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
difference.Normalize();
float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotZ + rotationOffset);
}
Comment
Your answer
Follow this Question
Related Questions
Relative Joint 2D weird reaction to full rotations 1 Answer
Get accurate Change in EulerAngles? 0 Answers
animation 360 rotation 1 Answer
Help with 2nd arm sprite rotation 1 Answer