Example #1
0
    // Update is called once per frame
    void Update()
    {
        leftHandControllerPosition  = MyInputManager.leftHandController.position;
        rightHandControllerPosition = MyInputManager.rightHandController.position;

        if (MyInputManager.TriggerValue('r') > 0 && col.bounds.Contains(rightHandControllerPosition))
        {
            transform.position = spline.WhereOnSpline(rightHandControllerPosition);
            outline.enabled    = true;
        }
        else
        {
            outline.enabled = false;
        }

        for (int i = 0; i < transform.childCount; i++)
        {
            if (i == NearestToken())
            {
                transform.GetChild(i).gameObject.SetActive(true);
            }
            else
            {
                transform.GetChild(i).gameObject.SetActive(false);
            }
        }
    }
    void Update()
    {
        if (transform.localPosition.x > 3 || transform.localPosition.y > 3 || transform.localPosition.z > 3 ||
            transform.localPosition.x < -3 || transform.localPosition.y < -3 || transform.localPosition.z < -3)
        {
            transform.localPosition = Vector3.up;
        }

        var position = new Vector3(transform.position.x - 7.829586f, transform.position.y - 0.9757428f, transform.position.z +
                                   3.546846f);

        //var position = transform.parent.localPosition;
        target.localPosition    = new Vector3(position.x * 3 * 1.7f, position.y * 1.7f, -position.z * 3 * 1.7f);
        target.localEulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z);

        handIndicator = MyInputManager.InRange(transform.position, 0.5f);


        if (handIndicator != '0')
        {
            if (!isGrabbed)
            {
                outline.enabled = true;
            }

            if (MyInputManager.GripValue(handIndicator) > 0 && !isGrabbed)
            {
                isGrabbed       = true;
                outline.enabled = false;
            }

            if (MyInputManager.GripValue(handIndicator) > 0 && !isGrabbed)
            {
                isGrabbed       = true;
                outline.enabled = false;
            }

            MoveClaws(MyInputManager.TriggerValue(handIndicator));

            if (isGrabbed && MyInputManager.GripValue(handIndicator) <= 0)
            {
                isGrabbed = false;
            }
        }
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        handIndicator = MyInputManager.HoveredByRayInteractor(_col);

        if (handIndicator != '0')
        {
            _outline.enabled = true;
            _selected        = true;
            if (MyInputManager.TriggerValue(handIndicator) <= 0)
            {
                _triggerPressed = false;
            }

            Debug.Log(!_triggerPressed + "," + (MyInputManager.TriggerValue(handIndicator) > 0) + "," + _selected);
            if (!_triggerPressed &&
                (MyInputManager.TriggerValue(handIndicator) > 0) &&
                _selected)
            {
                _triggerPressed = true;

                if (!_rotated)
                {
                    _animator.Play(closeAnim);
                    _rotated = true;
                }

                if (_rotated)
                {
                    _animator.Play(openAnim);
                    _rotated = false;
                }
            }
        }
        else
        {
            _outline.enabled = false;
            _selected        = false;
        }
    }
Example #4
0
    // Update is called once per frame
    private void Update()
    {
        if (disabled)
        {
            return;
        }

        #if UNITY_ANDROID
        bool fire = MyInputManager.TriggerValue('r') > 0.5f;
        #else
        bool fire = MyInputManager.Primary2DAxisClick('r');
        #endif

        if (remote.grabbed && fire)
        {
            primary2DAxis = MyInputManager.Primary2DAxis(remote.currHandIndicator);

            //explode
            if (primary2DAxis.y > 0 && primary2DAxis.x <= 0)
            {
                if (!expanded)
                {
                    expanded = true;
                    foreach (var ote in _objectsToExpand)
                    {
                        ote.Transform.localPosition = ote.Destination;
                    }
                    audioSource.pitch = 1;
                    audioSource.Play();
                }
                else
                {
                    expanded = false;
                    foreach (var ote in _objectsToExpand)
                    {
                        ote.Transform.localPosition = ote.Origin;
                    }
                    audioSource.pitch = -1;
                    audioSource.Play();
                }
                StartCoroutine(WaitForMilliseconds(500));
            }
            //Pause Rotation
            if (primary2DAxis.y > 0 && primary2DAxis.x > 0)
            {
                mercedesPodium.rotate = !mercedesPodium.rotate;
                rotationPaused        = !rotationPaused;
                StartCoroutine(WaitForMilliseconds(500));
            }
            //Rotate left
            if (primary2DAxis.y < 0 && primary2DAxis.x <= 0)
            {
                if (!rotationPaused)
                {
                    mercedesPodium.rotate = false;
                }

                device.transform.Rotate(new Vector3(0f, -mercedesPodium.rotationSpeed, 0f) * Time.deltaTime);

                if (!rotationPaused)
                {
                    mercedesPodium.rotate = true;
                }
            }
            //Rotate right
            if (primary2DAxis.y < 0 && primary2DAxis.x > 0)
            {
                if (!rotationPaused)
                {
                    mercedesPodium.rotate = false;
                }

                device.transform.Rotate(new Vector3(0f, mercedesPodium.rotationSpeed, 0f) * Time.deltaTime);

                if (!rotationPaused)
                {
                    mercedesPodium.rotate = true;
                }
            }
        }
    }
Example #5
0
    void Update()
    {
        prim2DAxis = MyInputManager.Primary2DAxis('r');

        if (!grabbed && Vector3.Distance(transform.position, MyInputManager.rightHandController.position) < grabbingDistance)
        {
            outline.enabled = true;
            if (MyInputManager.TriggerValue('r') > 0.5f)
            {
                outline.enabled = false;
                grabbed         = true;
                foreach (var mr in MyInputManager.rightHandController.GetComponentsInChildren <MeshRenderer>())
                {
                    mr.enabled = false;
                }

                enableDescriptionTextsFor(5);

                transform.parent   = MyInputManager.rightHandController.parent;
                transform.rotation = MyInputManager.rightHandController.rotation;
                transform.position = MyInputManager.rightHandController.position;

                currHandIndicator = 'r';
            }
        }
        else
        {
            outline.enabled = false;
        }

        if (grabbed)
        {
            if (prim2DAxis.x < 0.3 && prim2DAxis.y < 0.3 &&
                prim2DAxis.x > -0.3 && prim2DAxis.y > -0.3 &&
                MyInputManager.Primary2DAxisClick('r'))
            {
                transform.parent   = oldParent;
                transform.rotation = oldRotation;
                transform.position = oldPosition;

                if (currHandIndicator == 'r')
                {
                    foreach (var mr in MyInputManager.rightHandController.GetComponentsInChildren <MeshRenderer>())
                    {
                        mr.enabled = true;
                    }
                }


                grabbed = false;
                //outline.enabled = false;
            }
        }


        if (!enableDescriptionTexts)
        {
            if (MyInputManager.GripValue('r') > 0)
            {
                foreach (var meshRenderer in descriptionTexts.GetComponentsInChildren <MeshRenderer>())
                {
                    meshRenderer.enabled = true;
                }
            }
            else
            {
                foreach (var meshRenderer in descriptionTexts.GetComponentsInChildren <MeshRenderer>())
                {
                    meshRenderer.enabled = false;
                }
            }
        }
    }