# How do I rotate a bone using Gizmo-style via code?

I wanted to find out how I could move a character’s arms up and down in a straight way. After some trial and error I believe that it’s not sufficient to use just X, Y or Z rotation, but that all 3 have to be used instead.

At least I think so because at some point I found out that using the Rotation Gizmo tool would do exactely what I need.

I could simply play with the one axis (marked with red arrows in my screenshot), and it would move my arms up or down.

When I watched the rotation values in the Inspector, I saw that X, Y and Z rotation changes as I use this one Gizmo axis.

I am now wondering how I could implement this in code.

Is there a formula that would turn the degree value of the Gizmo tool into a Quaternion that I could use on the bone’s rotation?

Thank you!

Edit:

I have tried the following formula to simulate rotating via the Rotation Tool, but it doesn’t behave like the Rotation tool. I gues that is because the Rotation Tool provides new Rotation values for X, Y and Z, and in my attempt, I only provide new Y rotation.

``using System.Collections; using System.Collections.Generic; using UnityEngine;  public class MyPlayer : MonoBehaviour {     public Transform Shoulder;      private Quaternion _Rotation;     private float _f = 0f;      void Start()     {         _Rotation = Shoulder.rotation;     }      void Update()     {      }     private void OnGUI()     {         if (GUI.Button(new Rect(0, 70, 50, 30), "+"))         {             _f += 1;             Vector3 newRotation = _Rotation * new Vector3(0, _f, 0);              Shoulder.Rotate(newRotation, Space.World); // Space.Self also doesn't provide the desired results         }     } } ``