- Home /
Rotating an Object with Quaternion.FromToRotation
So, I´m getting a bizare behaviour,
I´m trying to Lerp an object to have it´s up, in the direction of another one. This works, If I put it in a Coroutine, but If I lerp it, it dosen´t work. It only rotates half as much, stopping at 45°...
desiredRot = Quaternion.FromToRotation(at.myArmor.up, hit.normal);
at.myArmor.localRotation = Quaternion.Lerp(at.myArmor.localRotation, desiredRot, Time.deltaTime);
Specifically, what I´m doing, is I´m trying to orient my character in relation with another object, for this, I´m doing a raycast, and geting the .normal, so I can orient my character´s Up, in relation with my characters position in relation with the object.
RaycastHit hit;
Vector3 direction = (planeReference.position - at.myBall.transform.position);
if (Physics.Raycast (at.myBall.transform.position, direction , out hit, 20)) {
desiredRot = Quaternion.FromToRotation(at.myArmor.up, hit.normal);
at.myArmor.localRotation = Quaternion.Lerp(at.myArmor.localRotation, desiredRot, Time.deltaTime);
}
Here are some images. First we have the character, and the cube that we want to get on, on the right
And here is me trying to orient myself, in relation to the cube. I only get halfway there. :s. !][2]][2]
Any ideas? Much appreciated
Your answer
Follow this Question
Related Questions
Transform rapidly spins when flipped upside down. 2 Answers
Calculate Rotation based on mesh normals 1 Answer
Get LookAt to work correctly with adjustment for rotated pivot 0 Answers
Player Rotating Oddly When Aligning to a Certain Normal 1 Answer
Doing 2D only rotation using FromToRotation + RotateTowards 0 Answers