コード例 #1
0
        //---------------------------------------------------------------------

        void Update()
        {
            // Send Tilt Input frame rate independent
            if (NetworkManager.getInstance().isActiveConnection&& InputManager.getInstance().isActiveTiltInput)
            {
                // send TiltValues every 1/rate second (e.g 1/15 = 15 times per second)
                if (timeSinceLastStart >= 1f / Network.sendRate)
                {
                    // FIXME
                    //WbCompRPCWrapper.getInstance().setTiltInput(this.getSmoothAxisValues());

                    float tiltValue = this.getSmoothAxisValues();
                    if (tiltValue > 0f)
                    {
                        WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.DRIVING_STEER_RIGHT, tiltValue);
                    }
                    else if (tiltValue < 0f)
                    {
                        WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.DRIVING_STEER_LEFT, -tiltValue);
                    }


                    timeSinceLastStart = 0;
                }
                timeSinceLastStart += Time.deltaTime;
            }
        }
コード例 #2
0
        //-----------------------------------------------------------------------------

        public void OnPointerUp(PointerEventData eventData)
        {
            this.isPressed = false;
            this.value     = 0f;

            WbCompStateSyncSending.getInstance().setVehicleInput(this.axisName, value);
        }
コード例 #3
0
        //-----------------------------------------------------------------------------

        public void Update()
        {
            if (this.isPressed)
            {
                value = Mathf.MoveTowards(value, this.targetValue, this.responseSpeed * Time.deltaTime);

                WbCompStateSyncSending.getInstance().setVehicleInput(this.axisName, value);
            }
        }
コード例 #4
0
        //-----------------------------------------------------------------------------

        private void updateInputValues(Vector2 delta)
        {
            // ------------------------------------------------------- //
            // Blendshape Order: 0 = UP, 1 = DOWN, 2 = LEFT, 3 = RIGHT //
            // ------------------------------------------------------- //

            // Thumbstick UP / Y-AXIS
            if (delta.y > 0 && delta.y > this.inputThreshold)
            {
                float blendshapeValue = Mathf.Lerp(0, 100f, Mathf.InverseLerp(0f, 1f, Mathf.Abs(delta.y)));
                this.meshThumbstick.GetComponent <SkinnedMeshRenderer>().SetBlendShapeWeight(0, blendshapeValue);
                this.meshThumbstick.GetComponent <SkinnedMeshRenderer>().SetBlendShapeWeight(1, 0);

                // send input key for vehicle interaction
                if (this.thumbstickType.Equals(ThumbstickType.Left))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_01_UP, Mathf.Clamp01(delta.y));
                }
                if (this.thumbstickType.Equals(ThumbstickType.Right))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_ROPE_UP, Mathf.Clamp01(delta.y));
                }
                // debugging
                this.updateThumbstickDebugUI(ThumbstickAxis.UP, Mathf.Clamp01(delta.y));
            }

            // Thumbstick DOWN / Y-AXIS
            if (delta.y < 0 && Mathf.Abs(delta.y) > this.inputThreshold)
            {
                float blendshapeValue = Mathf.Lerp(0, 100f, Mathf.InverseLerp(0f, 1f, Mathf.Abs(delta.y)));
                this.meshThumbstick.GetComponent <SkinnedMeshRenderer>().SetBlendShapeWeight(1, blendshapeValue);
                this.meshThumbstick.GetComponent <SkinnedMeshRenderer>().SetBlendShapeWeight(0, 0);

                // send input key for vehicle interaction
                if (this.thumbstickType.Equals(ThumbstickType.Left))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_01_DOWN, Mathf.Clamp01(Mathf.Abs(delta.y)));
                }
                if (this.thumbstickType.Equals(ThumbstickType.Right))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_ROPE_DOWN, Mathf.Clamp01(Mathf.Abs(delta.y)));
                }
                // debugging
                this.updateThumbstickDebugUI(ThumbstickAxis.DOWN, Mathf.Clamp01(Mathf.Abs(delta.y)));
            }

            // Thumbstick RESET Y-AXIS
            if ((Mathf.Abs(delta.y) > 0 || delta.y == 0) && Mathf.Abs(delta.y) < this.inputThreshold)
            {
                // send input key for vehicle interaction
                if (this.thumbstickType.Equals(ThumbstickType.Left))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_01_UP, 0f);
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_01_DOWN, 0f);
                }
                if (this.thumbstickType.Equals(ThumbstickType.Right))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_ROPE_UP, 0f);
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_ROPE_DOWN, 0f);
                }
                // debugging
                this.updateThumbstickDebugUI(ThumbstickAxis.UP, delta.y);
                this.updateThumbstickDebugUI(ThumbstickAxis.DOWN, delta.y);
            }

            // ----------------------------------------

            // Thumbstick LEFT / X-AXIS
            if (delta.x < 0 && Mathf.Abs(delta.x) > this.inputThreshold)
            {
                float blendshapeValue = Mathf.Lerp(0, 100f, Mathf.InverseLerp(0f, 1f, Mathf.Abs(delta.x)));
                this.meshThumbstick.GetComponent <SkinnedMeshRenderer>().SetBlendShapeWeight(2, blendshapeValue);
                this.meshThumbstick.GetComponent <SkinnedMeshRenderer>().SetBlendShapeWeight(3, 0);

                // send input key for vehicle interaction
                if (this.thumbstickType.Equals(ThumbstickType.Left))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_MAIN_LEFT, Mathf.Clamp01(Mathf.Abs(delta.x)));
                }
                if (this.thumbstickType.Equals(ThumbstickType.Right))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_FORWARD, Mathf.Clamp01(Mathf.Abs(delta.x)));
                }
                // debugging
                this.updateThumbstickDebugUI(ThumbstickAxis.LEFT, Mathf.Clamp01(Mathf.Abs(delta.x)));
            }

            // Thumbstick RIGHT / X-AXIS
            if (delta.x > 0 && delta.x > this.inputThreshold)
            {
                float blendshapeValue = Mathf.Lerp(0, 100f, Mathf.InverseLerp(0f, 1f, Mathf.Abs(delta.x)));
                this.meshThumbstick.GetComponent <SkinnedMeshRenderer>().SetBlendShapeWeight(3, blendshapeValue);
                this.meshThumbstick.GetComponent <SkinnedMeshRenderer>().SetBlendShapeWeight(2, 0);

                // send input key for vehicle interaction
                if (this.thumbstickType.Equals(ThumbstickType.Left))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_MAIN_RIGHT, Mathf.Clamp01(delta.x));
                }
                if (this.thumbstickType.Equals(ThumbstickType.Right))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_BACKWARD, Mathf.Clamp01(delta.x));
                }
                // debugging
                this.updateThumbstickDebugUI(ThumbstickAxis.RIGHT, Mathf.Clamp01(delta.x));
            }

            // Thumbstick RESET X-AXIS
            if ((Mathf.Abs(delta.x) > 0 || delta.x == 0) && Mathf.Abs(delta.x) < this.inputThreshold)
            {
                // send input key for vehicle interaction
                if (this.thumbstickType.Equals(ThumbstickType.Left))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_MAIN_LEFT, 0f);
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_MAIN_RIGHT, 0f);
                }
                if (this.thumbstickType.Equals(ThumbstickType.Right))
                {
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_FORWARD, 0f);
                    WbCompStateSyncSending.getInstance().setVehicleInput(InputKeys.TRUCKCRANE_BOOM_BACKWARD, 0f);
                }
                // debugging
                this.updateThumbstickDebugUI(ThumbstickAxis.LEFT, delta.x);
                this.updateThumbstickDebugUI(ThumbstickAxis.RIGHT, delta.x);
            }
        }