public void CustomUpdate()
    {
        limbMirror.MirrorServos();
        //hot fix
        //if (clearance > 3)
        //    clearance = 0;

        var clearance = memoryBridge.GetFloat(limbMirror.servoWrist.servoName + "KSPFootClearance");

        if (limbIK.gait)
        {
            ground.position = limbMirror.servoWrist.transform.position - new Vector3(0, clearance, 0);

            Debug.Log(name + " ground contact : " + memoryBridge.GetBool(limbMirror.servoWrist.servoName + "GroundContact"));

            var baseOffset = baseTarget.position.y - limbMirror.servoBase.transform.position.y;

            var globalPoint = limbIK.transform.TransformPoint(limbIK.gaitStartPos);
            globalPoint.y = ground.position.y;


            if (limbIK.legMode == RoboticLimbIK.LegMode.Translate)
            {
                globalPoint.y -= baseOffset;
            }

            limbIK.gait.localPosition = limbIK.transform.InverseTransformPoint(globalPoint);


            //  var tempPos = limbIK.gaitStartPos;
            //  tempPos.y = ground.position.y - baseOffset;//ground.position.y - baseOffset;
            ////  limbIK.gait.position = tempPos;//limbMirror.limbEnd.position;// - new Vector3(0, clearance, 0);
            //limbIK.gait.localPosition = tempPos;

            var tempEuler = limbIK.gait.eulerAngles;// = Vector3.zero;
            tempEuler.x = 0;
            // tempEuler.y = vesselControl.mirrorVessel.vesselOffset.eulerAngles.y;
            limbIK.gait.eulerAngles = tempEuler;

            limbIK.RunGait();

            if (debugClearance)
            {
                Debug.Log(Time.frameCount);
                Debug.Log("clearance " + clearance);
                // Debug.Log("mirror " + (float)Math.Round(limbMirror.limbEnd.transform.position.y, 2));
                // Debug.Log("gait " + limbIK.gait.position.y);
            }
        }

        // if (!IKactive)
        if (IKactive)
        {
            limbIK.RunIK();
        }

        limbIK.SetServos();
    }
Ejemplo n.º 2
0
 public void SetServos()
 {
     limbIK.SetServos();
 }