private void setTargetPoint(GameObject go, Vector3 translate) { targetPoint = new RectRotatePoint(go, translate); Attachable attach = targetPoint.gameObject.GetComponent <Attachable>(); attach.AddVelocity(velocity); }
void setEndPoint2(GameObject go, Vector2 translate) { if (endPoint2 != null) { this.disableEndPoint2(); } SpringJoint2D joint = go.AddComponent <SpringJoint2D>(); joint.enabled = false; joints[1] = joint; endPoint2 = new RectRotatePoint(go, translate); //sets the anchor on the current object; Collider2D tempcol = go.GetComponent <Collider2D>(); (float, float)size = (tempcol.bounds.size.x, tempcol.bounds.size.y); Attachable attach = go.GetComponent <Attachable>(); joint.anchor = new Vector2(translate.x / size.Item1 * attach.widthMultiplier, translate.y / size.Item2 * attach.heightMultiplier); if (endPoint1 != null) { joint.connectedBody = endPoint1.gameObject.GetComponent <Rigidbody2D>(); //SpringJoint2D joint2 = endPoint1.gameObject.GetComponent<SpringJoint2D>(); SpringJoint2D joint2 = joints[0]; joint2.enabled = false; joint.enabled = true; joint2.connectedBody = go.GetComponent <Rigidbody2D>(); //joints[0] = joint2; //sets the anchor on the connected object; Collider2D tempcol2 = endPoint1.gameObject.GetComponent <Collider2D>(); (float, float)size2 = (tempcol2.bounds.size.x, tempcol2.bounds.size.y); Attachable attach2 = endPoint1.gameObject.GetComponent <Attachable>(); joint.connectedAnchor = new Vector2(endPoint1.translate.x / size2.Item1 * attach2.widthMultiplier, endPoint1.translate.y / size2.Item2 * attach2.heightMultiplier); } configureJoints(); }
private void DismissTentative() { Attachable.focused = null; if (tentative == null) { return; } tentative = null; }
void DismissTentative2() { if (tentative2 == null) { return; } Attachable.focused = null; tentative2 = null; }
private void SetTentative(GameObject go, Vector3 translate) { Attachable attach = go.GetComponent <Attachable>(); if (attach == null) { return; } Attachable.focused = attach; tentative = new RectRotatePoint(go, translate); }
void SetTentative2(GameObject go, Vector2 translate) { if (tentative1 != null && tentative1.gameObject == go) { return; } Attachable attach = go.GetComponent <Attachable>(); if (attach == null) { return; } Attachable.focused = attach; tentative2 = new RectRotatePoint(go, translate); }