Quantcast
Channel: Questions in topic: "interpolate"
Viewing all articles
Browse latest Browse all 93

Rigidbody2D interpolation doesn't work properly

$
0
0
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 ![rigidobody2D][1] 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. ![alt text][2] 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. ![alt text][3] [1]: https://cdn.discordapp.com/attachments/333936584481177600/342289006308098049/unknown.png [2]: https://cdn.discordapp.com/attachments/333936584481177600/342290406823952388/unknown.png [3]: https://cdn.discordapp.com/attachments/333936584481177600/342353246959960081/unknown.png

Viewing all articles
Browse latest Browse all 93

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>