Rigidbody2D interpolation doesn't work properly
Hi, I'm using Unity 2017.1.0f3.
I have a simple object with Rigidbody2D on it, the rigidbody has settings like on the picture below
When I move the object by changing rigidbody's position in FixedUpdate, and visualize the position in the LateUpdate, the distance between positions isn't consistent, you can see it on the picture below.
From time to time there is a big gap between the positions, and it's very noticable in the game because the object is jerking.
Here is the script I use to move the object and display its positions.
using UnityEngine;
public class InterpolationTest : MonoBehaviour
{
public Rigidbody2D rb2d;
// Update is called once per frame
void FixedUpdate ()
{
rb2d.position = rb2d.position + Vector2.right * Time.fixedDeltaTime;
}
void LateUpdate()
{
Debug.DrawRay(transform.position, Vector3.up, Color.red, 5);
}
}
I'm wondering whether I do something wrong or it's a bug of Unity?
UPDATE: Those are not gaps. Well, those are, but the problem isn't in the bigger distance. At some frames the position of the character is the same.
On the pic below yellow lines are positions from the FixedUpdate, and red lines are from Update. I made them at different height so I would see if there are situations when the position is the same, and yeah, that's hapenning from time to time.
Your answer
Follow this Question
Related Questions
Mathf.Lerp for integers 1 Answer
Physics2D.Linecast unreliable with Rigidbody2D interpolation? What to do 1 Answer
Get a value that interpolates between two floats based on where character is facing 1 Answer
Collision Detection on Rb with Interpolation and Rb with Extrapolation does not work the same way. 0 Answers
Mesh looks like overlapping. 0 Answers