Ejemplo n.º 1
0
        protected virtual IEnumerator ReleaseStim(PositionPayload payload)
        {
            float t     = payload.position * growthFactorRelease;
            int   width = (int)Mathf.Lerp(offsetRelease, maxWidthReleaseT, t);

            Debug.Log(width);
            // Ramp up shortly
            ArmStimulation.StimulateArmBurst(
                new StimulationInfo(
                    Part.Triceps,
                    Side.Right,
                    width,
                    currentTriceps
                    ),
                burstDurationRelease
                );
            yield return(null);
            //yield return new WaitForSecondsRealtime(wristTricepsDelay / 1000f);

            //int width1 = (int)Mathf.Lerp(offsetRelease, maxWidthReleaseW, t);

            //ArmStimulation.StimulateArmBurst(
            //    new StimulationInfo(
            //        Part.Wrist,
            //        Side.Right,
            //        width1,
            //        current
            //    ),
            //    wristBurstDurationRelease
            //);
        }
Ejemplo n.º 2
0
        protected virtual void HandlePosition(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);

            float t      = (0.5f + payload.vector.x);
            int   widthL = (int)Mathf.Lerp(offset, tricepsL, (1 - t) * positionFactor);
            int   widthR = (int)Mathf.Lerp(offset, tricepsR, t * positionFactor);

            ArmStimulation.StimulateArm(
                Part.Triceps,
                Side.Left,
                widthL,
                currentTriceps
                );

            ArmStimulation.StimulateArm(
                Part.Triceps,
                Side.Right,
                widthR,
                currentTriceps
                );

            stopTime    = DateTime.Now.AddMilliseconds(500);
            stimulating = true;
        }
Ejemplo n.º 3
0
 protected virtual void ApplyStimulation()
 {
     ArmStimulation.StimulateArmBurst(
         stimInfo,
         duration
         );
 }
        protected virtual void ApplyStimulation()
        {
            if (payload.direction <= 0)
            {
                int width = (int)Mathf.Round(
                    getPulseWidth(
                        payload.direction,
                        payload.side == Side.Left ? maxWidthWristL : maxWidthWristR
                        )
                    );

                ArmStimulation.StimulateArm(
                    Part.Wrist,
                    payload.side,
                    width,
                    payload.side == Side.Left ? currentWristL : currentWristR
                    );
            }
            else
            {
                ChannelList.Stop();
                // normally apply to frist flexor
            }

            //stopTime = DateTime.Now.AddMilliseconds(500);
        }
        public override void HandleMessage(Message msg)
        {
            switch (msg.type)
            {
            case MessageType.Cube:
                base.HandleMessage(msg);

                //ArmStimulation.StimulateArm(
                //    Part.Triceps,
                //    side,
                //    offsetTriceps,
                //    currentTriceps
                //);
                break;

            case MessageType.CubeGrab:
                // Flat stimulation triceps only
                ArmStimulation.StimulateArm(
                    Part.Triceps,
                    Side.Left,
                    offsetTricepsL,
                    currentTricepsL
                    );
                ArmStimulation.StimulateArm(
                    Part.Triceps,
                    Side.Right,
                    offsetTricepsR,
                    currentTricepsR
                    );
                break;
            }
        }
Ejemplo n.º 6
0
        protected virtual void HandleImpact(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);

            if (payload.vector.Equals(Vector3.down))
            {
                StimulationInfo[] infos = new StimulationInfo[]
                {
                    new StimulationInfo(
                        Part.Triceps,
                        Side.Right,
                        impactWidth,
                        currentTriceps
                        ),
                    new StimulationInfo(
                        Part.Triceps,
                        Side.Left,
                        impactWidth,
                        currentTriceps
                        ),
                };
                // Ramp up shortly
                ArmStimulation.StimulateArmBurst(
                    infos,
                    impactDuration
                    );
            }
        }
        protected void HandleDetent(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);

            if (activeDetent < DateTime.Now)
            {
                if (payload.vector.x < 0)
                {
                    ArmStimulation.StimulateArmBurst(
                        new StimulationInfo(
                            Part.Biceps,
                            Side.Right,
                            widthDetentB,
                            currentDetentB
                            ),
                        detentDuration
                        );
                }
                else
                {
                    ArmStimulation.StimulateArmBurst(
                        new StimulationInfo(
                            Part.Triceps,
                            Side.Right,
                            widthDetentT,
                            currentDetentT
                            ),
                        detentDuration
                        );
                }
                activeDetent = DateTime.Now.AddMilliseconds(cooldownDetent);
            }
        }
Ejemplo n.º 8
0
 public void HandleBoxLedgeMsg(Message msg)
 {
     if (ledgeDuration > 0)
     {
         Debug.Log("Ledge");
         int current             = 15;
         StimulationInfo[] infos = new StimulationInfo[]
         {
             new StimulationInfo(
                 Part.Wrist,
                 Side.Right,
                 //Side.Left, // Wrist extensor
                 ledgeWidthWrist,
                 current
                 ),
             new StimulationInfo(
                 Part.Shoulder,
                 Side.Right,
                 ledgeWidthShoulder,
                 currentWrist
                 ),
         };
         // Ramp up shortly
         ArmStimulation.StimulateArmBurst(
             infos,
             ledgeDuration
             );
     }
 }
        public override void HandleMessage(Message msg)
        {
            SolidObjectPayload payload = JsonUtility.FromJson <SolidObjectPayload>(msg.payload);

            InitParameters(msg.payload);

            side = payload.side;

            float t = Mathf.InverseLerp(0, maxPenetration, penetration) * growthFactor;
            // Offset

            // Alwways stimulate wrist
            int widthWrist = (int)Mathf.Lerp(
                offsetWrist,
                maxWidthWrist,
                t);

            ArmStimulation.StimulateArm(
                Part.Wrist,
                side,
                widthWrist,
                currentWrist
                );

            float angle = Vector3.Angle(payload.cameraDirection, payload.handPosition);

            if (Mathf.Abs(Mathf.Sin(angle * Mathf.PI / 180)) > .5f)
            {
                // close to orthogonal => pushing sideways

                // Shoulder
                int widthShoulder = (int)Mathf.Lerp(
                    offsetShoulder,
                    maxWidthShoulder,
                    t);

                ArmStimulation.StimulateArm(
                    Part.Shoulder,
                    side,
                    widthShoulder,
                    currentShoulder
                    );
            }
            else
            {
                // pushing from the "front"
                // Biceps
                int widthBiceps = (int)Mathf.Lerp(
                    offsetBiceps,
                    maxWidthBiceps,
                    t);

                ArmStimulation.StimulateArm(
                    Part.Biceps,
                    side,
                    widthBiceps,
                    currentBiceps
                    );
            }
        }
        protected void HandleStatus(Message msg)
        {
            GenericStringPayload payload = JsonUtility.FromJson <GenericStringPayload>(msg.payload);

            bool value = bool.Parse(payload.payload);

            switch (payload.source)
            {
            case "Intensity":
                activeIntensity = value;
                // check last Detent
                if (activeIntensity && currentIntensity >= 0)
                {
                    //go to last detent
                    ArmStimulation.StimulateArm(
                        Part.OutwardsWrist,
                        Side.Right,
                        inDetentR,
                        current
                        );

                    targetIntensity = currentIntensity;
                }
                break;

            case "Color":
                activeColor = value;
                break;

            case "Thermo":
                activeThermo = value;
                break;
            }
        }
 protected void HandleElectro(Message msg)
 {
     ArmStimulation.StimulateArmBurst(
         new StimulationInfo(
             Part.Biceps,
             Side.Right,
             widthBiceps,
             currentBiceps),
         durationBiceps
         );
 }
 public void Update()
 {
     if (changing && invalidCombination())
     {
         ArmStimulation.StimulateArm(
             Part.InwardsWrist,
             Side.Right,
             inDetentR,
             current
             );
     }
 }
Ejemplo n.º 13
0
 protected virtual void ApplyStimulation()
 {
     for (int i = 0; i < 5; i++)
     {
         ArmStimulation.StimulateArmSinglePulse(
             Part.Wrist,
             side,
             maxPulseWidth,
             15
             );
     }
 }
Ejemplo n.º 14
0
        protected virtual void HandleArm(Message msg)
        {
            PositionPayload payload = JsonUtility.FromJson <PositionPayload>(msg.payload);

            int width = (int)Mathf.Lerp(offset, maxTricepsWidth, payload.position * growthFactor);

            ArmStimulation.StimulateArm(
                Part.Triceps,
                Side.Right,
                width,
                currentTriceps
                );

            stopTime    = System.DateTime.Now.AddMilliseconds(500);
            stimulating = true;
        }
Ejemplo n.º 15
0
        protected virtual void ApplyStimulation()
        {
            distance    = Mathf.Abs(distance);
            maxDistance = Mathf.Abs(maxDistance);

            int width = (int)Mathf.Round(getPulseWidth(distance, maxDistance, maxPulseWidth));

            ArmStimulation.StimulateArm(
                Part.Wrist,
                side,
                width,
                15
                );

            stopTime    = DateTime.Now.AddMilliseconds(500);
            stimulating = true;
        }
        protected void HandleButton(Message msg)
        {
            ContinuousPayload payload = JsonUtility.FromJson <ContinuousPayload>(msg.payload);

            float t = (payload.distance / payload.maxDistance) - 1;
            //Debug.Log(t);
            //return;

            int width = (int)Mathf.Lerp(buttonOffset, buttonWidth, t);

            ArmStimulation.StimulateArm(
                Part.Biceps,
                Side.Right,
                width,
                current
                );
        }
        protected override void ApplyStimulation()
        {
            offset = 0;
            bool firstHalf = distance < 0 ? true : false;

            maxDistance = Mathf.Abs(maxDistance);
            distance    = Mathf.Abs(distance);

            // Reversed: Starts strong but gets weaker in the middle
            distance = Mathf.Max(0, maxDistance - distance);

            int width = (int)Mathf.Round(getPulseWidth(distance, maxDistance, maxPulseWidth));

            //print(firstHalf ? width : -width);

            if (firstHalf)
            {
                ArmStimulation.StimulateArm(
                    Part.Biceps, // should be triceps
                    side,
                    width,
                    15
                    );
                ArmStimulation.StimulateArm(
                    Part.Wrist,
                    side,
                    0,
                    15
                    );
            }
            else
            {
                ArmStimulation.StimulateArm(
                    Part.Wrist,
                    side,
                    width,
                    15
                    );
                ArmStimulation.StimulateArm(
                    Part.Biceps, // should be triceps
                    side,
                    0,
                    15
                    );
            }
        }
        /**
         * Overwrite me
         */
        protected virtual void ApplyStimulation()
        {
            penetration    = Mathf.Abs(penetration);
            maxPenetration = Mathf.Abs(maxPenetration);

            int width = (int)Mathf.Round(getPulseWidth(penetration, maxPenetration, defaultMaxWidth));

            ArmStimulation.StimulateArm(
                Part.Wrist,
                side,
                width,
                15
                );

            stopTime    = DateTime.Now.AddMilliseconds(500);
            stimulating = true;
        }
Ejemplo n.º 19
0
        protected override void ApplyStimulation()
        {
            // how far the button was pressed
            distance = Mathf.Max(0, distance);
            // max push depth
            maxDistance = Mathf.Abs(maxDistance);
            int width, width1;

            if (distance < maxDistance)
            {
                // constant while able to push
                width  = offset;
                width1 = offset;
            }
            else
            {
                // scale for up to 10cm penetration
                float maxPen = 0.1f;
                float diff   = Mathf.Max(0, maxDistance + maxPen - distance);

                width = (int)Mathf.Round(getPulseWidth(
                                             diff, maxPen, wristUpdatePW));

                width1 = (int)Mathf.Round(getPulseWidth(
                                              diff, maxPen, shoulderUpdatePW));
            }

            ArmStimulation.StimulateArm(
                Part.Wrist,
                side,
                width,
                15
                );

            ArmStimulation.StimulateArm(
                Part.Shoulder,
                side,
                width1,
                15
                );

            stopTime = DateTime.Now.AddMilliseconds(500);
        }
Ejemplo n.º 20
0
        protected override void ApplyStimulation()
        {
            float pen = Mathf.Abs(penetration);


            int widthWrist, widthBiceps;

            if (penetration <= 0)
            {
                widthWrist  = 0;
                widthBiceps = 0;
            }
            else
            {
                // Penetration adjusted value
                widthWrist = (int)Mathf.Lerp(
                    offsetWrist,
                    maxWidthWrist,
                    pen * growthFactor);
                widthBiceps = (int)Mathf.Lerp(
                    offsetBiceps,
                    maxWidthBiceps,
                    pen * growthFactor);
            }

            ArmStimulation.StimulateArm(
                Part.Wrist,
                side,
                widthWrist,
                currentWrist
                );

            ArmStimulation.StimulateArm(
                Part.Biceps,
                side,
                widthBiceps,
                currentBiceps
                );

            stopTime    = DateTime.Now.AddMilliseconds(100);
            stimulating = true;
        }
Ejemplo n.º 21
0
        protected void HandleBoxTouchMsg(Message msg)
        {
            GenericStringPayload payload = JsonUtility.FromJson <GenericStringPayload>(msg.payload);

            float  t   = float.Parse(payload.payload);
            string src = payload.source;

            int width = (int)Mathf.Lerp(
                offsetTouchShoulder,
                src.Equals("Cube") ? touchShoulder : couchTouchShoulder,
                t * growthFactor);

            int width1 = (int)Mathf.Lerp(
                offsetTouchWrist,
                src.Equals("Cube") ? touchWrist : couchTouchWrist,
                t * growthFactor);

            if (t > 0)
            {
                Debug.Log("Touching: " + (t * growthFactor));
            }

            ArmStimulation.StimulateArm(
                //Part.Triceps,
                Part.Shoulder,
                Side.Right,
                width,
                currentShoulder
                );

            ArmStimulation.StimulateArm(
                Part.Wrist,
                Side.Right, // Wrist Extensor Right
                width1,
                currentWrist
                );

            stopTime    = DateTime.Now.AddMilliseconds(500);
            stimulating = true;
        }
Ejemplo n.º 22
0
        protected void HandleBoxMovingMsg(Message msg)
        {
            GenericStringPayload payload = JsonUtility.FromJson <GenericStringPayload>(msg.payload);

            float t = float.Parse(payload.payload);

            Debug.Log("Moving:" + t);

            string src = payload.source;

            int width = (int)Mathf.Lerp(
                src.Equals("Cube") ? moveOffsetShoulder : moveCouchOffsetShoulder,
                src.Equals("Cube") ? moveShoulder : moveCouchShoulder,
                t);
            int width1 = (int)Mathf.Lerp(
                src.Equals("Cube") ? moveOffsetWrist : moveCouchOffsetWrist,
                src.Equals("Cube") ? moveWrist : moveCouchWrist,
                t);

            ArmStimulation.StimulateArm(
                //Part.Triceps,
                Part.Shoulder,
                Side.Right,
                width,
                currentShoulder
                );

            ArmStimulation.StimulateArm(
                Part.Wrist,
                Side.Right,
                //Side.Left, // Wrist extensor
                width1,
                currentWrist
                );

            stopTime = DateTime.Now.AddMilliseconds(500);
        }
Ejemplo n.º 23
0
        protected virtual void HandleWallCollision(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);

            if (Mathf.Abs(payload.vector.z) < wallThreshold)
            {
                return;
            }

            // z-Axis looks to the left
            Side sideB = payload.vector.z > 0 ? Side.Left : Side.Right;
            Side sideT = payload.vector.z > 0 ? Side.Right : Side.Left;

            Debug.Log(payload.vector.z);

            StimulationInfo[] infos = new StimulationInfo[]
            {
                new StimulationInfo(
                    Part.Triceps,
                    sideT,
                    wallImpactWidthTriceps,
                    currentTriceps
                    ),
                new StimulationInfo(
                    Part.Biceps,
                    sideB,
                    wallImpactWidthBiceps,
                    currentBiceps
                    ),
            };
            // Ramp up shortly
            ArmStimulation.StimulateArmBurst(
                infos,
                wallImpactDuration
                );
        }
Ejemplo n.º 24
0
 // Use this for initialization
 private void Start()
 {
     instance  = this;
     list_full = false;
 }
        protected void HandleDialDetent(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);


            Debug.Log(payload.source + (payload.vector.x < 0).ToString());

            switch (payload.source)
            {
            case "Thermo":
                if (!activeThermo)
                {
                    break;
                }

                if (activeTimeThermo < DateTime.Now)
                {
                    if (payload.vector.x < 0)
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.InwardsWrist,
                                Side.Right,
                                inDetentR,
                                current
                                ),
                            detentDuration
                            );
                    }
                    else
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.OutwardsWrist,
                                Side.Right,
                                outDetentsR,
                                current
                                ),
                            detentDuration
                            );
                    }

                    activeTimeThermo = DateTime.Now.AddMilliseconds(cooldown);
                }
                break;

            case "Intensity":
                currentIntensity = (int)payload.vector.y;

                if (targetIntensity == currentIntensity)
                {
                    ChannelList.Stop();
                    targetIntensity = -1;
                    Debug.Log("Snapped to last Intensity");
                }

                if (changing && !invalidCombination())
                {
                    ChannelList.Stop();

                    Debug.Log("Changed To Valid Combination");
                    changing = false;
                }
                else if (invalidCombination())
                {
                    Debug.Log("Invalid Combination");
                    changing = true;
                }

                if (!activeIntensity)
                {
                    break;
                }

                if (activeTimeIntensity < DateTime.Now)
                {
                    if (payload.vector.x < 0)
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.InwardsWrist,
                                Side.Right,
                                inDetentR,
                                current
                                ),
                            detentDuration
                            );
                    }
                    else
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.OutwardsWrist,
                                Side.Right,
                                outDetentsR,
                                current
                                ),
                            detentDuration
                            );
                    }

                    activeTimeIntensity = DateTime.Now.AddMilliseconds(cooldown);
                }
                break;

            case "Color":
                if (!activeColor)
                {
                    break;
                }

                currentColor = (int)payload.vector.y;

                // snap to intensity 2
                if (invalidCombination())
                {
                    Debug.Log("Invalid Combination");
                    changing = true;
                }

                if (activeTimeColor < DateTime.Now)
                {
                    if (payload.vector.x < 0)
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.InwardsWrist,
                                Side.Left,
                                outDetentL,
                                current
                                ),
                            detentDuration
                            );
                    }
                    else
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.OutwardsWrist,
                                Side.Left,
                                inDetentL,
                                current
                                ),
                            detentDuration
                            );
                    }

                    activeTimeColor = DateTime.Now.AddMilliseconds(cooldown);
                }
                break;
            }
        }
        public override void HandleMessage(Message msg)
        {
            if (!isActiveAndEnabled)
            {
                return;
            }

            switch (msg.type)
            {
            case MessageType.WalkthroughDial:
                HandleDial(msg);
                break;

            case MessageType.WalkthroughDialDetent:
                HandleDialDetent(msg);
                break;

            case MessageType.WalkthroughDialStatus:
                HandleStatus(msg);
                break;

            case MessageType.WalkthroughButton:
                HandleButton(msg);
                break;

            case MessageType.WalkthroughButtonContact:
                if (activeButton < DateTime.Now)
                {
                    //ArmStimulation.StimulateArmBurst(
                    //    new StimulationInfo(
                    //        Part.Biceps,
                    //        Side.Right,
                    //        ButtonI,
                    //        current
                    //    ),
                    //    1000
                    //);

                    ArmStimulation.StimulateArmBurst(
                        new StimulationInfo(
                            Part.InwardsWrist,
                            Side.Right,
                            inwardsR,
                            current
                            ),
                        detentDuration
                        );

                    Debug.Log("Button Press");

                    activeButton = DateTime.Now.AddSeconds(1);
                }
                break;

            case MessageType.WalkthroughButtonPosition:
                trackingHandler.HandleMessage(msg);
                break;

            case MessageType.EscapeElectro:
            case MessageType.EscapeDetent:
                escapeHandler.HandleMessage(msg);
                break;
            }
        }
Ejemplo n.º 27
0
    // Use this for initialization
    private void Start()
    {
        instance = this;
//        Debug.Log("Arm Stimulation initialized");
    }
Ejemplo n.º 28
0
        public override void HandleMessage(Message msg)
        {
            SolidObjectPayload payload = JsonUtility.FromJson <SolidObjectPayload>(msg.payload);

            InitParameters(msg.payload);

            side = payload.side;

            // higher cos => more aligned

            float rightCos = Mathf.Cos(
                Vector3.Angle(
                    payload.cameraDirections[0],
                    payload.handDirection)
                * Mathf.PI / 180)
            ;

            float upCos = Mathf.Cos(
                Vector3.Angle(
                    payload.cameraDirections[1],
                    payload.handDirection)
                * Mathf.PI / 180)
            ;

            float frontCos = Mathf.Cos(
                Vector3.Angle(
                    payload.cameraDirections[1],
                    payload.handDirection)
                * Mathf.PI / 180)
            ;

            float max = Mathf.Max(
                Mathf.Abs(rightCos),
                Mathf.Abs(upCos),
                Mathf.Abs(frontCos)
                );

            // Check relative direction

            bool useWrist    = false;
            bool useBiceps   = false;
            bool useShoulder = false;

            if (max == Mathf.Abs(rightCos))
            {
                // From the side
                useWrist    = true;
                useShoulder = true;
            }
            else if (max == Mathf.Abs(upCos))
            {
                // Top or bottom
                useWrist  = true;
                useBiceps = upCos > 0;
            }
            else
            {
                // Front or back
                useWrist  = true;
                useBiceps = frontCos > 0;
            }

            // Apply stimulation

            float t = Mathf.InverseLerp(0, maxPenetration, penetration) * growthFactor;

            // Wrist
            if (useWrist)
            {
                // Alwways stimulate wrist
                int widthWrist = (int)Mathf.Lerp(
                    offsetWrist,
                    maxWidthWrist,
                    t);

                if (penetration <= 0)
                {
                    widthWrist = 0;
                }

                ArmStimulation.StimulateArm(
                    Part.Wrist,
                    side,
                    widthWrist,
                    currentWrist
                    );
            }

            // Biceps
            if (useBiceps)
            {
                int widthBiceps = (int)Mathf.Lerp(
                    offsetBiceps,
                    maxWidthBiceps,
                    t);

                if (penetration <= 0)
                {
                    widthBiceps = 0;
                }

                ArmStimulation.StimulateArm(
                    Part.Biceps,
                    side,
                    widthBiceps,
                    currentBiceps
                    );
            }

            // Shoulder
            if (useShoulder)
            {
                // Shoulder
                int widthShoulder = (int)Mathf.Lerp(
                    offsetShoulder,
                    maxWidthShoulder,
                    t);

                if (penetration <= 0)
                {
                    widthShoulder = 0;
                }

                ArmStimulation.StimulateArm(
                    Part.Shoulder,
                    side,
                    widthShoulder,
                    currentShoulder
                    );
            }
        }
        protected override void ApplyStimulation()
        {
            // how far the button was pressed
            float pen = Mathf.Max(0, penetration);

            // max push depth
            maxPenetration = Mathf.Abs(maxPenetration);
            int widthWrist, widthBiceps;


            int currentWrist = side == Side.Left ?
                               currentWristL:
                               currentWristR;
            int currentBiceps = side == Side.Left ?
                                currentBicepsL:
                                currentBicepsR;

            int offsetWrist = side == Side.Left ?
                              offsetWristL :
                              offsetWristR;
            int offsetBicpes = side == Side.Left ?
                               offsetBicepsL :
                               offsetBicepsR;

            if (pen < minPenetration)
            {
                // scale for initial contact
                int maxWidthWrist = side == Side.Left ?
                                    maxWidthWristL :
                                    maxWidthWristR;
                widthWrist = (int)Mathf.Lerp(
                    0,
                    offsetWrist,                     // stub
                    (pen / minPenetration));

                int maxWidthBiceps = side == Side.Left ?
                                     maxWidthBicepsL :
                                     maxWidthBicepsR;
                widthBiceps = (int)Mathf.Lerp(
                    0,
                    offsetBicpes,                     // stub
                    (pen / minPenetration));
            }
            else if (pen < maxPenetration)
            {
                // scale for moving
                // constant while able to push
                widthWrist  = offsetWrist;
                widthBiceps = offsetBicpes;
            }
            else
            {
                // scale for moving
                // constant while able to push
                int maxWidthWrist = side == Side.Left ?
                                    maxWidthWristL :
                                    maxWidthWristR;
                widthWrist = (int)Mathf.Lerp(
                    offsetWrist,
                    maxWidthWrist,
                    growthFactor * (pen - maxPenetration) / (1 - maxPenetration));

                int maxWidthBiceps = side == Side.Left ?
                                     maxWidthBicepsL :
                                     maxWidthBicepsR;
                widthBiceps = (int)Mathf.Lerp(
                    offsetBicpes,
                    maxWidthBiceps,
                    growthFactor * (pen - maxPenetration) / (1 - maxPenetration));
            }

            if (penetration <= 0)
            {
                widthWrist  = 0;
                widthBiceps = 0;
            }

            ArmStimulation.StimulateArm(
                Part.Wrist,
                side,
                widthWrist,
                currentWrist
                );

            ArmStimulation.StimulateArm(
                Part.Biceps,
                side,
                widthBiceps,
                currentBiceps
                );

            stopTime = DateTime.Now.AddMilliseconds(500);
        }
Ejemplo n.º 30
0
 // Use this for initialization
 private void Start()
 {
     instance = this;
 }