Moving static colliders in Unity 2D

There’s a lot of warnings about moving static colliders, but I’m a bit confused about static colliders in 2D.

I have an infinite runner game where the ground is spawned when the player moves. To avoid lots of Destroy and Instantiate calls I’m using a pooling system. The ground consists of groundblock gameobjects that simply have a box collider attached. No rigidbody. When the player moves forward, I’m effectively moving blocks from behind the player to infront of him. Hence, I’m moving static colliders - a big no-no. How do I remedy this? The approach in 3D would be to attach a rigidbody to my groundblocks, check isKinematic and change groundblock.rigidbody.position, which is a lot faster than groundblock.transform.position on a static collider. However, the Rigidbody2D doesn’t have a position member, nor does it have a movePosition method.

What’s the approach here?

If the rigidbody is Kinematic you can just change Transform.position. If you scroll all the way to the bottom of the Rigidbody Component Documentation page you will find this line:

If you are directly manipulating the Transform component of your object but still want physics, attach a Rigidbody and make it Kinematic.

Essentially, Kinematic means that it’s movements will not be governed by the physics system but it will still interact with physics objects.