void Awake() { // Find the ik component ik = GetComponent <IK>(); if (foot != null) { if (footUpAxis == Vector3.zero) { footUpAxis = Quaternion.Inverse(foot.rotation) * Vector3.up; } lastFootLocalRotation = foot.localRotation; ik.GetIKSolver().OnPostUpdate += AfterIK; } }
void Start() { // 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 * mechSpider.scale); }