Hello! I want to connect two 2d objects with a joint that keeps one object above the other object. I tried the distance joint however it doesn’t keep the objects the way I want (One is circling around another.) Is there a way to keep 2d objects connected at the same distance away with one object above the other object?
You can write a simple code, that does that.
Example (in jscript):
var parent : GameObject //The object at the bottom
var Distance : float //The distance between the two object's
function Update () {
transform.position = parent.transform.position + Vector3(0,Distance,0);
}
The good thing about this, that the Distance is variable very easily.
1 Like
You can use a combination of joints so for instance you can use a DistanceJoint2D to maintain the distance and a HingeJoint2D with an angle limit to maintain one object ‘above’ another.
You can directly modify the transform as suggested above but don’t do so unless you’re using a Rigidbody2D set to be Kinematic.
1 Like
Thanks!