# how should I multiply A quaternion by a Vector three to rotate an object.

I am new to game development and this is my first time asking a question here. I am writing a script to rotate an object with w and s being the x axis, a and d being z axis, and q and e being y axis. I am using this script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hand : MonoBehaviour
{
public GameObject camera;
public Quaternion rotation;
public Vector3 set;

``````    // Update is called once per frame
private void Update()
{
if (Input.GetKey(KeyCode.W))
{
set.z += 0.5f;
}
if (Input.GetKey(KeyCode.S))
{
set.z += -0.5f;
}
if (Input.GetKey(KeyCode.A))
{
set.x += -0.5f;
}
if (Input.GetKey(KeyCode.D))
{
set.x += 0.5f;
}
if (Input.GetKey(KeyCode.E))
{
set.y += 0.5f;
}
if (Input.GetKey(KeyCode.Q))
{
set.y += -0.5f;
}

rotation = camera.transform.rotation;
rotation *= Quaternion.Euler(0, set.y, 0);
rotation *= Quaternion.Euler(set.x, 0, 0);
rotation *= Quaternion.Euler(0, 0, set.z);

transform.rotation = rotation;
}
}
``````

This almost works but when I rotate along the x axis and then rotate along the y axis it rotates like it is being rotated locally but I want it to rotate like it is globally. Once again I am sorry if I used any wrong terminology or made any more mistakes

To achieve global rotation, you should first apply the rotation to a temporary Vector3 and then convert it back to a Quaternion. Something like this (Warning pseudocode):

``````using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Hand : MonoBehaviour
{
public GameObject camera;
public Quaternion rotation;
public Vector3 set;

// Update is called once per frame
private void Update()
{
if (Input.GetKey(KeyCode.W))
{
set.z += 0.5f;
}
if (Input.GetKey(KeyCode.S))
{
set.z += -0.5f;
}
if (Input.GetKey(KeyCode.A))
{
set.x += -0.5f;
}
if (Input.GetKey(KeyCode.D))
{
set.x += 0.5f;
}
if (Input.GetKey(KeyCode.E))
{
set.y += 0.5f;
}
if (Input.GetKey(KeyCode.Q))
{
set.y += -0.5f;
}

rotation = camera.transform.rotation;
Vector3 eulerAngles = rotation.eulerAngles;
eulerAngles += set;
rotation = Quaternion.Euler(eulerAngles);

transform.rotation = rotation;
}
}
``````