'How do you multiply a quanternion by a vector3 in unity?

I have this code:

private Transform player;
// Start is called before the first frame update
void Start()
{
    player = Object.FindObjectOfType<PlayerIdentifier>().transform;
}

// Update is called once per frame
void Update()
{
    float newPosX = (Quaternion.AngleAxis(player.rotation.z, Vector2.up) * player.position).x;
    float newPosY = (Quaternion.AngleAxis(transform.rotation.z,Vector2.up)*transform.position).y;
    Vector3 newPos = new Vector3(newPosX, newPosY);
    newPos = newPos * Quaternion.AngleAxis(transform.rotation.z, Vector2.up);
    transform.position = newPos;
}

You see, I am getting an error on the 13th line saying that Quanternions cannot be multiplied by Vector3. Any way to multiply them without an error message?



Solution 1:[1]

Nevermind, you have to put the Quanternion before the Vector3 Like this Quaternion qua = Quanternion.Euler(0,0,90); Vector3 vect = new Vector3(0,1,0); Vector3 output=qua*vect;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1