コード例 #1
0
        //bool groundContact = false;
        public void CustomUpdate()
        {
            //var angleOffset = memoryBridge.GetVector3(servoName + "adjustedOffset");

            // if (angleOffset != Vector3.zero)
            //    Debug.Log(name + " set adjusted offset");
            //    servoAnchor.localEulerAngles = angleOffset;
            memoryBridge.SetFloat(servoName + "servoPos", servo.Position);


            servo.MoveTo(memoryBridge.GetFloat(servoName + "unityServoPos"), memoryBridge.GetFloat(servoName + "unityServoSpeed"));

            anchorChild.rotation = part.transform.rotation;
            if (this.servo.HostPart.name == "IR.Rotatron.Basic.v3")
            {
                anchorChild.localEulerAngles += new Vector3(0, 0, 90);
            }
            memoryBridge.SetVector3(servoName + "servoLocalEuler", anchorChild.localEulerAngles);
            memoryBridge.SetQuaternion(servoName + "servoLocalRot", anchorChild.localRotation);



            //var servoAngle = memoryBridge.GetFloat(servoName + "ServoSetPos");
            //var servoSpeed = memoryBridge.GetFloat(servoName + "ServoSetSpeed");
            //if (servoAngle < 200)
            //    servo.MoveTo(servoAngle, servoSpeed);
        }
コード例 #2
0
        public void CustomUpdate()
        {
            var clientAutoPilot = memoryBridge.GetBool("ClientAutoPilotActive");

            if (clientAutoPilot & !autoPilot)
            {
                ToggleAutoPilot(true);
            }
            else if (!clientAutoPilot & autoPilot)
            {
                ToggleAutoPilot(false);
            }

            ReadClientInputs();

            //  Debug.Log(memoryBridge.GetFloat("TestFloatValue"));
            //   vesselTransform.localPosition = memoryBridge.GetVector3("VesselTransformLocalPos"+memoryBridge.fileName);
            vesselCOM.localPosition = vessel.localCoM;
            var vesselCOMoffset = vesselCOM.InverseTransformPoint(vessel.vesselTransform.position);

            memoryBridge.SetVector3("AdjustedVesselCOMoffset" + memoryBridge.fileName, vesselCOMoffset);
            var gimbalUp = vessel.mainBody.transform.position - vesselCOM.position;

            gimbal.LookAt(gimbalUp);
            gimbal.eulerAngles += gimbalOffset;//memoryBridge.GetVector3("GimbalOffset");

            //  adjustedGimbal.LookAt(gimbalUp,vessel.vesselTransform.position);
            // var tempEuler = adjustedGimbal.localRotation;
            //tempEuler.x = 0;
            //tempEuler.z = 0;
            //adjustedGimbal.localRotation = tempEuler;

            var vesselGimbleOffset = Quaternion.Inverse(gimbal.rotation) * adjustedVessel.rotation;//gimbal.eulerAngles - vesselTransform.eulerAngles;

            memoryBridge.SetQuaternion("VesselGimbleOffset" + memoryBridge.fileName, vesselGimbleOffset);

            CheckVesselClearance();

            IRmanager.CustomUpdate();


            if (autoPilot)
            {
                rollInput  = memoryBridge.GetFloat("VesselRoll");
                yawInput   = memoryBridge.GetFloat("VesselYaw");
                pitchInput = memoryBridge.GetFloat("VesselPitch");
            }
        }
コード例 #3
0
        public void CustomUpdate()
        {
            //var angleOffset = memoryBridge.GetVector3(servoName + "adjustedOffset");

            // if (angleOffset != Vector3.zero)
            //    Debug.Log(name + " set adjusted offset");
            //    servoAnchor.localEulerAngles = angleOffset;
            memoryBridge.SetFloat(servoName + "servoPos", servo.Position);

            //var acceleration = memoryBridge.GetFloat(servoName + "unityServoAcceleration");
            //if (servo.Acceleration != acceleration && acceleration != 0)
            //    servo.Acceleration = acceleration;



            //
            if (Input.GetKey(KeyCode.Keypad5))
            {
                // Debug.Log("start moving servo");
                running = true;
                //   servo.MoveTo(memoryBridge.GetFloat(servoName + "unityServoPos"), memoryBridge.GetFloat(servoName + "unityServoSpeed"));
                servo.MoveTo(90, 5);
            }
            // if(running)
            servo.MoveTo(memoryBridge.GetFloat(servoName + "unityServoPos"), memoryBridge.GetFloat(servoName + "unityServoSpeed"));
            // servo.mo

            anchorChild.rotation = part.transform.rotation;
            if (this.servo.HostPart.name == "IR.Rotatron.Basic.v3")
            {
                anchorChild.localEulerAngles += new Vector3(0, 0, 90);
            }
            memoryBridge.SetVector3(servoName + "servoLocalEuler", anchorChild.localEulerAngles);
            memoryBridge.SetQuaternion(servoName + "servoLocalRot", anchorChild.localRotation);



            //var servoAngle = memoryBridge.GetFloat(servoName + "ServoSetPos");
            //var servoSpeed = memoryBridge.GetFloat(servoName + "ServoSetSpeed");
            //if (servoAngle < 200)
            //    servo.MoveTo(servoAngle, servoSpeed);
        }