Beispiel #1
0
        //join with other shape by FixedJoint2D
        public bool JoinTo(MeshBase otherMesh)
        {
            FixedJoint2D C_FJ2D = gameObject.AddComponent <FixedJoint2D>();

            C_FJ2D.connectedBody = otherMesh.GetComponent <Rigidbody2D>();
            if (C_FJ2D.connectedBody == null)
            {
                return(false);
            }
            C_FJ2D.anchor = transform.InverseTransformPoint(transform.position);
            C_FJ2D.anchor = otherMesh.transform.InverseTransformPoint(otherMesh.transform.position);
            return(true);
        }
Beispiel #2
0
        //joins two shapes by FixedJoint2D
        public static bool Join(MeshBase meshA, MeshBase meshB)
        {
            FixedJoint2D C_FJ2D = meshA.gameObject.AddComponent <FixedJoint2D>();

            C_FJ2D.connectedBody = meshB.GetComponent <Rigidbody2D>();
            if (C_FJ2D.connectedBody)
            {
                return(false);
            }
            C_FJ2D.anchor = meshA.transform.InverseTransformPoint(meshA.transform.position);
            C_FJ2D.anchor = meshB.transform.InverseTransformPoint(meshB.transform.position);
            return(true);
        }