- Home /
Question by
Metorphium · Oct 05, 2016 at 06:21 PM ·
rotationquaternionoffset
Give the Quaternion Rotation an offset of 90°
By the Results i got from researching im not really able to give my GameObject a 90° Offset Rotation.
The relevant script is:
void Rotating (float lh, float lv)
{
Vector3 targetDirection = new Vector3 (lh, 0f, lv);
Quaternion targetRotation = Quaternion.LookRotation (movement, Vector3.up);
Quaternion newRotation = Quaternion.Lerp (GetComponent<Rigidbody> ().rotation, targetRotation, turnSmoothing * Time.deltaTime);
GetComponent<Rigidbody>().MoveRotation(newRotation);
}
The main problem is that when i move forward the Character is looking to the left, when i move to the left he's looking back etc....
Comment
Can you not just go;
Quaternion targetRotation = Quaternion.LookRotation (movement, Vector3.up) * Quaternion.Euler (0, 90, 0);
Would need to multiply, not add IIRC. Unless you convert them both to Vector3 as euler, add them, and then apply.
Good point, not quite sure what I was thinking there.