Is there a way to fake a 2D fixed joint?

I’m trying to make a simple physics game and I want to get objects in my game to stick together when they collide without having to use parenting because there will be multiple sticky objects. The closest i’ve come so far is to add multiple distance joints to attach the objects together, but i can’t figure out how to calculate the distance between the anchor and connected anchor because they’re both in local positions.

If anyone knows either how i can calculate the distance between the two anchor points on collision, or even a better way to fake a 2D fixed joint i’d really appreciate it.

Thanks

I think what you’re looking for is Transform.TransformPoint and Transform.InverseTransformPoint.

TransformPoint will convert a coordinate from local to world space and Inverse does the opposite. With this it’s as simple as picking a point on one object, transforming it to world space, and attaching a point on the other object to that world position.

You could also try a fixedjoint. fixedjoint is in 3d physics but it should work in 2d space as well. I’ve always avoided Physics2D because regular physics has more features and works in 2d space anyways.