Beispiel #1
0
        /// <summary>
        /// Sets the direction of movement of the joint on every update
        /// </summary>
        /// <param name="jointIndex">Index of the link selected in the Articulation Chain</param>
        private void UpdateDirection(int jointIndex)
        {
            float        moveDirection = Input.GetAxis("Vertical");
            JointControl current       = articulationChain[jointIndex].GetComponent <JointControl>();

            if (previousIndex != jointIndex)
            {
                JointControl previous = articulationChain[previousIndex].GetComponent <JointControl>();
                previous.direction = RotationDirection.None;
                previousIndex      = jointIndex;
            }

            if (current.controltype != control)
            {
                UpdateControlType(current);
            }

            if (moveDirection > 0)
            {
                current.direction = RotationDirection.Positive;
            }
            else if (moveDirection < 0)
            {
                current.direction = RotationDirection.Negative;
            }
            else
            {
                current.direction = RotationDirection.None;
            }
        }
Beispiel #2
0
 public void UpdateControlType(JointControl joint)
 {
     joint.controltype = control;
     if (control == ControlType.PositionControl)
     {
         ArticulationDrive drive = joint.joint.xDrive;
         drive.stiffness    = stiffness;
         drive.damping      = damping;
         joint.joint.xDrive = drive;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Sets the direction of movement of the joint on every update
        /// </summary>
        /// <param name="jointIndex">Index of the link selected in the Articulation Chain</param>
        private void UpdateDirection(int jointIndex)
        {
            bool SelectionInput1;
            bool SelectionInput2;

            if (left)
            {
                SelectionInput1 = Input.GetKey("w");
                SelectionInput2 = Input.GetKey("s");
            }
            else
            {
                SelectionInput1 = Input.GetKey("up");
                SelectionInput2 = Input.GetKey("down");
            }

            ArticulationBody actualJoint = articulationChain[jointIndex];
            JointControl     current     = articulationChain[jointIndex].GetComponent <JointControl>();

            if (previousIndex != jointIndex)
            {
                JointControl previous = articulationChain[previousIndex].GetComponent <JointControl>();
                previous.direction = RotationDirection.None;
                previousIndex      = jointIndex;
            }

            if (current.controltype != control)
            {
                UpdateControlType(current);
            }

            if (SelectionInput1)
            {
                current.direction = RotationDirection.Positive;
            }
            else if (SelectionInput2)
            {
                current.direction = RotationDirection.Negative;
            }
            else
            {
                current.direction = RotationDirection.None;
            }
            print(actualJoint.xDrive.target);
        }
Beispiel #4
0
        public void UpdateDirection(int jointIndex)
        {
            JointControl current = articulationChain[jointIndex].GetComponent <JointControl>();



            if (current.controltype != control)
            {
                UpdateControlType(current);
            }

            if (moveDirection > 0)
            {
                current.direction = RotationDirection.Positive;
            }
            else if (moveDirection < 0)
            {
                current.direction = RotationDirection.Negative;
            }
            else
            {
                current.direction = RotationDirection.None;
            }
        }
 private void Start()
 {
     jointControl = GetComponent <JointControl>();
 }