Comments and answers for "Slerp to make the right/left side face another object"
http://answers.unity.com/questions/1624845/slerp-to-make-the-rightleft-side-face-another-obje.html
The latest comments and answers for the question "Slerp to make the right/left side face another object"Answer by highpockets
http://answers.unity.com/answers/1624962/view.html
You should never set the directional vectors of a transform, you will get very strange results sometimes because setting transform.right does not necessarily mean that transform.forward or transform.up will end up where you want them.
----------
You should get the axis to rotate first (if transform.right is exactly 180 degrees away from direction, you will have to rotate just a smidge for this to work) :
----------
if(-transform.right == direction){
transform.Rotate(0, 0.1f, 0); //rotate a smidge on the y axis to get less than 180 degrees
}
Vector3 axis = Vector3.Cross( transform.right, direction );
----------
Now get your angle:
----------
float angle = Mathf.Sqrt(Vector3.Dot(direction, direction) * Vector3.Dot(transform.right, transform.right)) + Vector3.Dot(direction, transform.right);
----------
Now create your quaternion:
----------
Quaternion newRot = new Quaternion(axis.x, axis.y, axis.z, angle).normalized;
----------
Now we get our target rotation based on this new rotation we need to apply to our existing rotation:
----------
Quaternion targetRotation = newRot * transform.rotation;
----------
Now apply that to slerp:
----------
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, timer);
timer = timer + Time.deltaTime;
----------
That should work for you.
CheersMon, 22 Apr 2019 22:35:15 GMThighpocketsComment by Magso on Magso's comment
http://answers.unity.com/comments/1624952/view.html
Make both sides Transform variables and reference them like so
Quaternion leftSideRotation = Quaternion.LookRotation(target.position - leftSide.position);
Quaternion rightSideRotation = Quaternion.LookRotation(target.position - rightSide.position);
leftSide.rotation = Quaternion.Slerp(leftSide.rotation, leftSideRotation, Time.deltaTime * damping);
rightSide.rotation = Quaternion.Slerp(rightSide.rotation, rightSideRotation, Time.deltaTime * damping);Mon, 22 Apr 2019 21:40:48 GMTMagsoComment by Saif_youssef89 on Saif_youssef89's answer
http://answers.unity.com/comments/1624948/view.html
Yes, but what if i want to rotate so that my Left side is facing the other object.Mon, 22 Apr 2019 21:35:12 GMTSaif_youssef89Answer by Magso
http://answers.unity.com/answers/1624929/view.html
public float damping;
Quaternion rotation = Quaternion.LookRotation(target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
This is took from the old standard assets SmoothLookAtMon, 22 Apr 2019 20:52:27 GMTMagso