private void SetFoot(Foot foot) { float weight = foot.GetWeight(this.animator); if (foot.hit) { Vector3 rotationAxis = Vector3.Cross(Vector3.up, foot.normal); float angle = Vector3.Angle(transform.up, foot.normal); Quaternion rotation = Quaternion.AngleAxis(angle * weight, rotationAxis); this.animator.SetIKRotationWeight(foot.footIK, weight); this.animator.SetIKRotation(foot.footIK, rotation * this.animator.GetIKRotation(foot.footIK)); float baseHeight = this.transform.position.y - FOOT_OFFSET_Y; float animHeight = (foot.foot.position.y - baseHeight) / (rotation * Vector3.up).y; Vector3 position = new Vector3( foot.foot.position.x, Mathf.Max(foot.height, baseHeight) + animHeight, foot.foot.position.z ); this.animator.SetIKPositionWeight(foot.footIK, weight); this.animator.SetIKPosition(foot.footIK, position); } else { this.animator.SetIKPositionWeight(foot.footIK, weight); this.animator.SetIKRotationWeight(foot.footIK, weight); } }