public override void Attach(DirectionalArrow arrow, Transform arrowTransform, Jonko joint) { playField = FindObjectOfType <PlayField>().gameObject; GameObject newStick = Instantiate(Resources.Load("Stick", typeof(GameObject)) as GameObject, playField.transform); float halfObjectLength = newStick.GetComponent <AttachToStick>().stick.GetComponent <MeshRenderer>().bounds.extents.y; newStick.transform.rotation = arrowTransform.rotation; Vector3 normalizedDir = (arrowTransform.position - transform.position).normalized; Vector3 dir1or0 = new Vector3(Mathf.RoundToInt(normalizedDir.x), Mathf.RoundToInt(normalizedDir.y), 0); newStick.transform.position = anchor.transform.position + (dir1or0 * jointOffset); if (joint != null) { HingeJoint newHingeJoint = joint.gameObject.AddComponent <HingeJoint>(); newHingeJoint.connectedBody = newStick.GetComponent <Rigidbody>(); } else { if (anchor.GetComponent <FixedJoint>()) { anchor.GetComponent <FixedJoint>().connectedBody = newStick.GetComponentInChildren <Rigidbody>(); anchor.GetComponent <FixedJoint>().connectedAnchor = new Vector3(0, 2, 0); } else if (anchor.GetComponent <HingeJoint>()) { anchor.GetComponent <HingeJoint>().connectedBody = newStick.GetComponentInChildren <Rigidbody>(); anchor.GetComponent <HingeJoint>().connectedAnchor = new Vector3(0, 2, 0); } } base.Attach(arrow, arrowTransform, joint); }
public override void Attach(DirectionalArrow arrow, Transform arrowTransform, Jonko joint) { playField = FindObjectOfType <PlayField>().gameObject; GameObject newStick = Instantiate(Resources.Load("JointAndStick", typeof(GameObject)) as GameObject, playField.transform); newStick.transform.rotation = arrow.gameObject.transform.rotation; Vector3 normalizedDir = (arrowTransform.position - transform.position).normalized; Vector3 dir1or0 = new Vector3(Mathf.RoundToInt(normalizedDir.x), Mathf.RoundToInt(normalizedDir.y), 0); newStick.transform.position = stick.transform.position + (dir1or0 * jointOffset); stick.AddFixedJoint(); stick.ConnectRigidBody(newStick.transform.Find("HingeJoint").GetComponent <Rigidbody>()); base.Attach(arrow, arrowTransform, joint); createEndItem.visible = false; createEndItem.ApplyVisibility(); }
public virtual void Attach(DirectionalArrow arrow, Transform arrowTransform, Jonko joint) { arrow.visible = false; arrow.ApplyVisibility(); }
public void ToggleJoint() { Instantiate(jointPrefab, transform.position + (transform.position - attachedToStick.transform.position).normalized * jointOffset, transform.rotation); Jonko connectionJoint = jointPrefab.GetComponent <Jonko>(); }
public void RemoveConnectionJoint(Jonko connectionJoint) { Joints.Remove(connectionJoint); //CheckConnectionJointRequirementMet(); CheckAllRequirements(); }
public void AddConnectionJoint(Jonko connectionJoint) { Joints.Add(connectionJoint); //CheckConnectionJointRequirementMet(); CheckAllRequirements(); }