// Find all necessary components and initiate public void Start() { animator = GetComponent <Animator>(); allIKComponents = (IK[])GetComponentsInChildren <IK>(); disabledIKComponents = new bool[allIKComponents.Length]; fixTransforms = new bool[allIKComponents.Length]; if (ik != null) { ik.GetIKSolver().OnPostUpdate += AfterLastIK; } // Gather all the rigidbodies and their associates Rigidbody[] rigidbodies = (Rigidbody[])GetComponentsInChildren <Rigidbody>(); int firstIndex = rigidbodies[0].gameObject == gameObject? 1: 0; rigidbones = new Rigidbone[firstIndex == 0? rigidbodies.Length: rigidbodies.Length - 1]; for (int i = 0; i < rigidbones.Length; i++) { rigidbones[i] = new Rigidbone(rigidbodies[i + firstIndex]); } // Find all the child Transforms Transform[] C = (Transform[])GetComponentsInChildren <Transform>(); children = new Child[C.Length - 1]; for (int i = 0; i < children.Length; i++) { children[i] = new Child(C[i + 1]); } }
private void DestroyLegs(IK[] ikComponents) { for (int i = 0; i < ikComponents.Length; i++) { IK iK = ikComponents[i]; if (iK != null) { IKSolver expr_1F = iK.GetIKSolver(); expr_1F.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(expr_1F.OnPreUpdate, new IKSolver.UpdateDelegate(this.OnSolverUpdate)); IKSolver expr_46 = iK.GetIKSolver(); expr_46.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(expr_46.OnPostUpdate, new IKSolver.UpdateDelegate(this.OnPostSolverUpdate)); } } }
void Update() { if (ik == null) { return; } if (ik.fixTransforms) { ik.GetIKSolver().FixTransforms(); } // Apply animation here if necessary ik.GetIKSolver().Update(); }
public void Start() { if (twistSolvers.Length == 0) { Debug.LogError("TwistRelaxer has no TwistSolvers. TwistRelaxer.cs was restructured for FIK v2.0 to support multiple relaxers on the same body part and TwistRelaxer components need to be set up again, sorry for the inconvenience!", transform); return; } foreach (TwistSolver twistSolver in twistSolvers) { twistSolver.Initiate(); } if (ik != null) { ik.GetIKSolver().OnPostUpdate += OnPostUpdate; } }
private void OnDestroy() { if (this.initiated) { IK[] array = this.legs; for (int i = 0; i < array.Length; i++) { IK iK = array[i]; if (iK != null) { IKSolver expr_2F = iK.GetIKSolver(); expr_2F.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(expr_2F.OnPreUpdate, new IKSolver.UpdateDelegate(this.OnSolverUpdate)); IKSolver expr_56 = iK.GetIKSolver(); expr_56.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(expr_56.OnPostUpdate, new IKSolver.UpdateDelegate(this.OnPostSolverUpdate)); } } } }
void Start() { if (parent == null) { parent = transform.parent; } if (child == null) { if (transform.childCount == 0) { var children = parent.GetComponentsInChildren <Transform>(); for (int i = 1; i < children.Length; i++) { if (children[i] != transform) { child = children[i]; break; } } } else { child = transform.GetChild(0); } } twistAxis = transform.InverseTransformDirection(child.position - transform.position); axis = new Vector3(twistAxis.y, twistAxis.z, twistAxis.x); // Axis in world space Vector3 axisWorld = transform.rotation * axis; // Store the axis in worldspace relative to the rotations of the parent and child axisRelativeToParentDefault = Quaternion.Inverse(parent.rotation) * axisWorld; axisRelativeToChildDefault = Quaternion.Inverse(child.rotation) * axisWorld; if (ik != null) { ik.GetIKSolver().OnPostUpdate += OnPostUpdate; } }
void Start() { // Find the ik component ik = GetComponent<IK>(); // Workaround for Unity Win Store/Phone serialization bug stepProgress = 1f; hit = new RaycastHit(); var points = ik.GetIKSolver().GetPoints(); position = points[points.Length - 1].transform.position; hit.point = position; // Store the default rest position of the leg defaultPosition = mechSpider.transform.InverseTransformPoint(position + offset); }
void Start() { ik = GetComponent <IK>(); ik.GetIKSolver().Initiate(ik.transform); }