Guides Physics 2D Joints Use FixedJoint2D

Physics 2D Joints 1 min read Updated Apr 2026

Use FixedJoint2D

`FixedJoint2D` locks two bodies together as if they were rigidly attached.

Use it when you want separate rigidbodies to behave like one connected piece.

Good Fits

FixedJoint2D is useful for:

  • welded props
  • temporary rigid attachments
  • composite moving rigs
  • physics objects that should stay locked together

Scene Setup

  1. Add Rigidbody2D to the body you want to lock.
  2. Add FixedJoint2D.
  3. Assign Connected Body.
  4. Place Anchor and Connected Anchor.
  5. Leave Enable Collision off unless you deliberately want the connected bodies to keep colliding with each other.

Practical Example: A Two-Part Crate Rig

Imagine a crate with a decorative top piece that still needs to move as part of the same rigid assembly.

  1. Add Rigidbody2D to the moving piece.
  2. Add FixedJoint2D.
  3. Connect it to the main crate body.
  4. Align the anchors where the pieces should lock together.

Now the rig stays physically connected without needing to merge everything into one sprite or one collider setup.

PHP Example

<?php

use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\FixedJoint2D;
use Lenga\Engine\Core\Vector3;

class LockRigTogether extends Behaviour
{
    public function awake(): void
    {
        $joint = $this->gameObject->getComponent(FixedJoint2D::class);
        if ($joint === null) {
            return;
        }

        $joint->autoConfigureConnectedAnchor = false;
        $joint->anchor = new Vector3(0.0, 0.5, 0.0);
        $joint->connectedAnchor = new Vector3(0.0, -0.5, 0.0);
        $joint->enableCollision = false;
    }
}

Related Guides