Question by
jsabandal1 · Nov 27, 2017 at 06:16 PM ·
rotationquaternionrotate
Does anyone know how to convert this rotation to lerp
public void SimulateGravity(Transform body)
{
Vector2 targetDirection = (body.position - transform.position).normalized;
Vector2 bodyUp = body.up;
body.GetComponent<Rigidbody2D>().AddForce(targetDirection * gravity * Time.deltaTime, ForceMode2D.Impulse);
body.rotation = Quaternion.FromToRotation(bodyUp, targetDirection) * body.rotation;
// make the line at the bottom work
Quaternion.Lerp(MyRotation, ToRotation, 1.0f);
}
Comment
Best Answer
Answer by Legend_Bacon · Nov 27, 2017 at 06:31 PM
Hello there,
Quaternion.Lerp RETURNS a value, so you probably want to do body.rotation = Quaternion.Lerp(MyRotation, ToRotation, 1.0f);
instead.
Since you're dealing with Quaternions, I would also recommend using Quaternion.Slerp() instead, it's usually more precise.
Hope that helps!
~LegendBacon
Thank you! I figured it out and this is how I did it. I appreciate the comment.
Your answer
Follow this Question
Related Questions
Rotate around a point with a specific angle 0 Answers
More problems with arrow shooting 0 Answers
Setting a quaternion's rotation value 0 Answers
How to smoothly rotate the object? 2 Answers
Rotating camera not working? 0 Answers