I have a bunch of asteroids that act as moving platforms. They move off the left edge of the screen, and reappear at the right side of the screen. They have very simple code that looks like so:
private void FixedUpdate() {
Vector3 new_position = new Vector3(transform.position.x + _velocity.x * Time.deltaTime, transform.position.y + _velocity.y * Time.deltaTime, 0f);
_rigidbody2d.MovePosition(new_position);
// Check if we looped to right side
if (transform.position.x < _boundary.x) {
float amt_boundary_was_crossed = Mathf.Abs(_boundary.x - transform.position.x);
transform.position = new Vector3(_line_start.x + amt_boundary_was_crossed, transform.position.y, 0f);
}
}
I had them working in the previous version of Unity I was using (2022.1.1). However, I recently upgraded to a new version of Unity (2023.2.20), and notice that the moving platform asteroid now behave erroneously.
before::
after:
Before, the asteroids moved in an orderly fashion, all moving at the same speed, never colliding with eachother. Now, it looks like the asteroids are now possibly colliding against other objects on the loop back. Strangely, disabling the collider2d, setting rigidbdy.isKinematic to true, or changing the object’s collision layer doesn’t seem to prevent this strange bumping.
Was there a major change to Unity’s physics in the past couple of years? Does anyone know what this is?