Пример #1
0
 public static void createMotors(LegController l)
 {
     l.walkMotor.maxMotorTorque = l.maxWalkForce;
     l.walkMotor.motorSpeed = -l.desiredWalkPower;
     l.opposedMotor.maxMotorTorque = l.maxWalkForce;
     l.opposedMotor.motorSpeed = l.desiredWalkPower;
     l.setMotor.maxMotorTorque = l.maxWalkForce;
     l.setMotor.motorSpeed = 0;
 }
Пример #2
0
 public static void updateMotor(LegController lc, HingeJoint2D j, MotorMotion m)
 {
     switch (m) {
     case	MotorMotion.FREE:
         j.useMotor = false;
         break;
     case MotorMotion.BACKWARD:
         j.useMotor = true;
         j.motor = lc.opposedMotor;
         break;
     case MotorMotion.FORWARD:
         j.useMotor = true;
         j.motor = lc.walkMotor;
         break;
     case MotorMotion.SET:
         j.useMotor = true;
         j.motor = lc.setMotor;
         break;
     default:
         break;
     }
 }
Пример #3
0
        /*
        public static IEnumerator advanceOneLeg (LegController c, Leg advancingLeg, Leg helpingLeg)
        {
            yield return new WaitForFixedUpdate ();
            if(c.owner.legsPattern1.pauseOnStateChange) {
                Debug.Log("Breaking for change to pattern 1");
                Debug.Break();
                yield return new WaitForFixedUpdate ();
            }
            LegController.updateMotors (advancingLeg, advancingLeg.owner.legsPattern1.advancer.thigh, advancingLeg.owner.legsPattern1.advancer.shin);
            LegController.updateMotors (helpingLeg, helpingLeg.owner.legsPattern1.helper.thigh, helpingLeg.owner.legsPattern1.helper.shin);
            while (advancingLeg.hipToKnee.jointAngle - 1f > advancingLeg.hipToKneeTargetAngle) {
                yield return new WaitForFixedUpdate ();
            }

            if(advancingLeg.owner.legsPattern2.pauseOnStateChange) {
                Debug.Log("Breaking for change to pattern 2");
                Debug.Break();
                yield return new WaitForFixedUpdate ();
            }

            LegController.updateMotors (advancingLeg, advancingLeg.owner.legsPattern2.advancer.thigh, advancingLeg.owner.legsPattern2.advancer.shin);
            LegController.updateMotors (helpingLeg, helpingLeg.owner.legsPattern2.helper.thigh, helpingLeg.owner.legsPattern2.helper.shin);
            while (advancingLeg.kneeToFoot.jointAngle - 1f > advancingLeg.kneeToFootTargetAngle) {
                yield return new WaitForFixedUpdate ();
            }
        }*/
        public static IEnumerator walkRoutine(LegController c, Leg leg1, Leg leg2)
        {
            LegController.createMotors(c);

            //yield return leg1.owner.StartCoroutine(advanceOneLeg (leg1, leg2));
            //yield return leg2.owner.StartCoroutine(advanceOneLeg (leg2, leg1));

            yield return null;
        }
Пример #4
0
 public static void updateMotors(LegController lc, Leg l, MotorMotion h2k, MotorMotion k2f)
 {
     updateMotor(lc, l.rootToBend,h2k);
     updateMotor(lc, l.bendToEnd,k2f);
     l.state = "HipKnee: " + h2k + ", KneeFoot: " + k2f;
 }