Quaternion * Vector does not work (and its not about the order)
Hi! Newbie here. I'm trying to rotate a camera around the player. I am taking a vector that starts at the player position and ends at the camera, and multiply it by a quaternion. The result is... well, the camera is where it should be, but there is no rotation. No errors either.
void Start () {
offset = transform.position - player.transform.position ;
}
void FixedUpdate () {
var xTurnAxis = Input.GetAxis("Horizontal Turn") * Time.deltaTime * 150.0f;
Vector3 rotatedOffset = Quaternion.Euler(0,xTurnAxis,0) * offset;
transform.position = rotatedOffset + player.transform.position;
}
I made a different scene to test if I'm doing something wrong with the quaternion multiplication and its seems that it does not always work. For example, this rotates the vector just fine:
Vector3 idk = Quaternion.Euler(0, 45, 0) * transform.forward;
While this does not:
transform.position = Quaternion.Euler(0, 45, 0) * new Vector3(0, (transform.position.y + 0.05f), 0);
I feel like I'm missing something obvious here.
Your answer
Follow this Question
Related Questions
Rotating objects around other without rotating itself 1 Answer
unity 2d rotation flipping on y axis upside-down problems 0 Answers
3D Look at Mouse relative to Camera direction 0 Answers
[Unity C#] I want to control the rotation. 0 Answers
how do I rezolve "look rotation viewing vector is zero"? 1 Answer