Example #1
0
        private void TriggerUp(stExternalInteractData _externalInteractData)
        {
            //Debug.Log("Trigger Up : " + name + " " + _externalInteractData.HandType);
            if (isRequestedGrabMessage)
            {
                return;
            }

            bool isGrab = VRHandEventHandler.IsGrab(_externalInteractData.HandType, this);

            if (isGrab)
            {
                isRequestedGrabMessage = true;
                Vector3    pos      = Pivot.position;
                Quaternion rot      = Pivot.rotation;
                Vector3    velocity = VRInputManager.GetVelocity(_externalInteractData.HandType, VRInputManager.PositionType.CONTROLLER);

                if (m_bIsOnlyLocalObject)
                {
                    m_GrabData.SetUnGrabData(_externalInteractData.HandType, pos, rot, velocity, Time.time);
                    UnGrabSomething();
                }
                else
                {
                    //Debug.Log("Send UnGrab : " + name + " " + _externalInteractData.HandType);
                    MyNetworkManager.SendToServer_UnGrab(UID, _externalInteractData.HandType, pos, rot, velocity);
                }
            }
        }
Example #2
0
        protected override void OnGrabbing()
        {
            if (m_GrabData.AmIGrabbing)
            {
                if (!m_bIsAblePulling)
                {
                    Vector3 handWorldPosition = VRInputManager.GetControllerPosition(m_GrabData.HandType, VRInputManager.PositionType.CONTROLLER);

                    //m_vCurrentPullingPosition = handWorldPosition;
                    m_vPrevPullingPosition = handWorldPosition;
                    return;
                }
                if (m_PullType == PullType.Position)
                {
                    CalculatePosition();
                }
                else if (m_PullType == PullType.Rotation)
                {
                    CalculateRotation();
                }
                CheckLimitVlaue();
                onChangePullValue?.Invoke();
                TranslatePullingTarget(m_fPulledValue);

                if (m_comunicationData.IsAbleSend)
                {
                    SendPullData();
                }
            }
            else
            {
                float pullValue = Mathf.Lerp(m_fPrevPulledvalue, m_fPulledValue, m_comunicationData.UpdateDelta);
                TranslatePullingTarget(pullValue);
            }
        }
Example #3
0
        private void ExecuteIsDeviceOutOfBoundary()
        {
            if (g_refSelectedDetector == null)
            {
                return;
            }

            Vector3 head                    = VRInputManager.GetDevicePosition(VRInputManager.PositionType.HMD);
            Vector3 leftHand                = VRInputManager.GetControllerPosition(VRHand.eHandType.Left, VRInputManager.PositionType.CONTROLLER);
            Vector3 RightHand               = VRInputManager.GetControllerPosition(VRHand.eHandType.Right, VRInputManager.PositionType.CONTROLLER);
            bool    isInIgnoreZoneHead      = false;
            bool    isInIgnoreZoneLeftHand  = false;
            bool    isInIgnoreZoneRightHand = false;

            if (g_stIgnoreBoundaryArea != null)
            {
                isInIgnoreZoneHead      = g_stIgnoreBoundaryArea.Contains(head);
                isInIgnoreZoneLeftHand  = g_stIgnoreBoundaryArea.Contains(leftHand);
                isInIgnoreZoneRightHand = g_stIgnoreBoundaryArea.Contains(RightHand);
            }



            bool isInHead      = g_refSelectedDetector.IsPointInBoundary_Renewal(head);
            bool isInLeftHand  = g_refSelectedDetector.IsPointInBoundary_Renewal(leftHand);
            bool isInRightHand = g_refSelectedDetector.IsPointInBoundary_Renewal(RightHand);

            g_refBoundaryRenderer.SetLeftHandPosition(isInIgnoreZoneLeftHand, leftHand);
            g_refBoundaryRenderer.SetRightHandPosition(isInIgnoreZoneRightHand, RightHand);

            isInHead      = isInHead || isInIgnoreZoneHead;
            isInLeftHand  = isInLeftHand || isInIgnoreZoneLeftHand;
            isInRightHand = isInRightHand || isInIgnoreZoneRightHand;

            bool isInAll = isInHead && isInLeftHand && isInRightHand;

            if (m_bWasHeadInsideOfBoundary != isInHead)
            {
                onBoundHead?.Invoke(isInHead);
            }
            if (m_bWasLeftHandInsideOfBoundary != isInLeftHand)
            {
                onBoundLeftHand?.Invoke(isInLeftHand);
            }
            if (m_bWasRightHandInsideOfBoundary != isInRightHand)
            {
                onBoundRightHand?.Invoke(isInRightHand);
            }
            if (m_bWasAllInsideOfBoundary != isInAll)
            {
                onBoundAll?.Invoke(isInAll);
            }


            m_bWasHeadInsideOfBoundary      = isInHead;
            m_bWasLeftHandInsideOfBoundary  = isInLeftHand;
            m_bWasRightHandInsideOfBoundary = isInRightHand;
            m_bWasAllInsideOfBoundary       = isInAll;
        }
Example #4
0
    // Use this for initialization
    void Start()
    {
        gun = GetComponentInChildren <GrenadeGunManager>();
        right.TriggerClicked += new ControllerInteractionEventHandler(OnTriggerClicked);

        left.GripPressed += new ControllerInteractionEventHandler(OnGripPressed);
        instance          = this;
    }
Example #5
0
 private void MyUpdateControllerData()
 {
     m_isButtonPressedChanged = false;
     if (m_isButtonPressed != VRInputManager.GetIsControllerButtonPressed())
     {
         m_isButtonPressedChanged = true;
         m_isButtonPressed        = VRInputManager.GetIsControllerButtonPressed();
     }
 }
Example #6
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this);
         Debug.LogError("VRInputManager already exist destroying script attatched too : " + transform.name);
     }
 }
Example #7
0
        private void CalculatePosition()
        {
            m_fPrevPulledvalue = m_fPulledValue;
            //m_vPrevPullingPosition = m_vCurrentPullingPosition;
            Vector3 currentHandPosition = m_vCurrentPullingPosition = VRInputManager.GetControllerPosition(m_GrabData.HandType, VRInputManager.PositionType.CONTROLLER);
            Vector3 delta = currentHandPosition - m_vPrevPullingPosition;

            float dot = Vector3.Dot(m_vWorldPullingAxis, delta);

            m_vPrevPullingPosition = currentHandPosition;
            m_fPulledValue        += dot;
        }
Example #8
0
 protected override void OnGrab()
 {
     base.OnGrab();
     if (MyNetworkManager.IsMyID(m_GrabData.GrabberID))
     {
         Vector3 handWorldPosition = VRInputManager.GetControllerPosition(m_GrabData.HandType, VRInputManager.PositionType.CONTROLLER);
         m_vPrevPullingPosition    = /*m_vCurrentPullingPosition =*/ handWorldPosition;
         prevPullingTargetPosition = m_tmPullingTarget.position;
         MyNetworkManager.SendToServer_FloatValue(MyNetworkManager.NET_GAME_MESSAGE.MSG_SYNC_PULL_VALUE, UID, m_fPulledValue);
         m_comunicationData.Send();
     }
 }
Example #9
0
 private void Awake()
 {
     if (Instance && Instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
 }
Example #10
0
    private PointerEventData GetPointerEventData()
    {
        // Currently the module is made for a single controller with one button.
        // That means that we only have a single pointer.
        if (null == m_pointerEventData)
        {
            m_pointerEventData = new PointerEventData(eventSystem);
        }

        if (VRInputManager.GetControllerActive())
        {
            m_pointerEventData.position = m_cameraCenter;

            m_pointerEventData.scrollDelta = Vector2.zero;
            m_pointerEventData.button      = PointerEventData.InputButton.Left;
            eventSystem.RaycastAll(m_pointerEventData, m_RaycastResultCache);
            var raycast = FindFirstRaycast(m_RaycastResultCache);

            // Delta is used to define if the cursor was moved.
            // We will also use it for drag threshold calculation, for which we'll store world distance
            // between the last and the current raycasts (will actually use sqrmagnitude for its speed).
            Ray     ray      = new Ray(uiCamera.transform.position, uiCamera.transform.forward);
            Vector3 hitPoint = ray.GetPoint(raycast.distance);
            m_pointerEventData.delta = new Vector2((hitPoint - m_lastRaycastHitPoint).sqrMagnitude, 0);
            m_lastRaycastHitPoint    = hitPoint;

            m_pointerEventData.pointerCurrentRaycast = raycast;

            // Debug
            if (m_RaycastResultCache.Count > 0)
            {
                WriteDebug("Raycast hit " + raycast.gameObject.name);
            }

            m_RaycastResultCache.Clear();
        }

        return(m_pointerEventData);
    }
Example #11
0
        private void CalculateRotation()
        {
            Vector3 currentHandPosition = m_vCurrentPullingPosition = VRInputManager.GetControllerPosition(m_GrabData.HandType, VRInputManager.PositionType.CONTROLLER);

            Vector3 prevDirection    = m_vPrevPullingPosition - prevPullingTargetPosition;
            Vector3 currentDirection = currentHandPosition - m_tmPullingTarget.position;

            Vector3 crossFromAxisToPrev = Vector3.Cross(prevDirection, m_vWorldPullingAxis);

            Vector3 crossFromAxisToCurrent = Vector3.Cross(currentDirection, m_vWorldPullingAxis);
            Vector3 crossPrevCurrent       = Vector3.Cross(crossFromAxisToPrev, crossFromAxisToCurrent).normalized;
            float   crossAngle             = Vector3.Angle(crossFromAxisToPrev, crossFromAxisToCurrent);

            float dot = Vector3.Dot(crossPrevCurrent, m_vWorldPullingAxis);

            float finalAngle = crossAngle * dot;

            m_fPrevPulledvalue        = m_fPulledValue;
            m_vPrevPullingPosition    = currentHandPosition;
            prevPullingTargetPosition = m_tmPullingTarget.position;
            m_fPulledValue           += finalAngle;
        }
Example #12
0
 void Start()
 {
     input = GameObject.Find("[CameraRig]").GetComponent <VRInputManager>();
 }
 // Start is called before the first frame update
 void Start()
 {
     input          = GameObject.Find("[CameraRig]").GetComponent <VRInputManager>();
     LeftCollision  = false;
     RightCollision = false;
 }
Example #14
0
		//Initialize function, if want to make non event type, just set _type as null
		public void Initialize(string[] slideName, VRInputManager.TutorialInputType? _type, bool isAnimation, float playTime ){
			LoadSlides (slideName);
			if (_type != null) {
				_inputType = _type;
			}
			_isAnimation = isAnimation; _playTime = playTime; _eventFlag = false;
		}
Example #15
0
 public void OnButtonReleased(VirtualButtonAbstractBehaviour vb)
 {
     VRInputManager.SetIsControllerButtonPressed(false);
 }
Example #16
0
        public static void SeedInputs(VRInputManager manager)
        {
            var axisList                = new List <InputAxis>();
            var inputManagerAsset       = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
            var serializedObject        = new UnityEditor.SerializedObject(inputManagerAsset);
            var inputManagerCurrentData = serializedObject.FindProperty("m_Axes");

            /// this part is done in the most stuoid way possible but I couldn;t figure another way of doing it
            #region populating input
            List <InputAxis> inputAxes = new List <InputAxis>();
            switch (manager.type)
            {
            case ControllerType.Normal:
                inputAxes = new List <InputAxis>
                {
                    new InputAxis()
                    {
                        name            = manager.LeftTrigger,
                        descriptiveName = "Device trigger axis",
                        axis            = 9,
                        type            = 2
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftGrip,
                        descriptiveName = "Device grip axis",
                        axis            = 11,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftThumb,
                        descriptiveName = "Device thumb proximity touch axis",
                        dead            = 0.19f,
                        axis            = 15,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightTrigger,
                        descriptiveName = "Device trigger axis",
                        axis            = 10,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightGrip,
                        descriptiveName = "Device grip axis",
                        axis            = 12,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightThumb,
                        descriptiveName = "Device thumb proximity touch axis",
                        dead            = 0.19f,
                        axis            = 16,
                        type            = 2,
                    }
                };
                break;

            case ControllerType.Knuckles:
                inputAxes = new List <InputAxis>
                {
                    new InputAxis()
                    {
                        name            = manager.LeftIndex,
                        descriptiveName = "Left Index Finger for a Knuckles Style controller",
                        axis            = 21,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftMiddle,
                        descriptiveName = "Left Middle Finger for a Knuckles Style controller",
                        axis            = 23,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftRing,
                        descriptiveName = "Left Ring Finger for a Knuckles Style controller",
                        axis            = 25,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftPinky,
                        descriptiveName = "Left Pinky Finger for a Knuckles Style controller",
                        axis            = 27,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.LeftThumb,
                        descriptiveName = "Device thumb proximity touch axis",
                        dead            = 0.19f,
                        axis            = 15,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightIndex,
                        descriptiveName = "Right Index Finger for a Knuckles Style controller",
                        axis            = 22,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightMiddle,
                        descriptiveName = "Right Middle Finger for a Knuckles Style controller",
                        axis            = 24,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightRing,
                        descriptiveName = "Right Ring Finger for a Knuckles Style controller",
                        axis            = 26,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightPinky,
                        descriptiveName = "Right Pinky Finger for a Knuckles Style controller",
                        axis            = 28,
                        type            = 2,
                    },
                    new InputAxis()
                    {
                        name            = manager.RightThumb,
                        descriptiveName = "Device thumb proximity touch axis",
                        dead            = 0.19f,
                        axis            = 16,
                        type            = 2,
                    }
                };
                break;

            default:
                break;
            }

            for (int i = 0; i < inputAxes.Count; i++)
            {
                if (!ElementExsists(inputAxes[i].name, inputManagerCurrentData))
                {
                    AddAxe(inputAxes[i], ref inputManagerCurrentData);
                }
            }

            #endregion

            serializedObject.ApplyModifiedProperties();
        }
Example #17
0
 private void OnEnable()
 {
     manager = (VRInputManager)target;
 }
Example #18
0
 private void OnDisable()
 {
     Instance = null;
 }
Example #19
0
    void Update()
    {
        VRInputManager.SetIsControllerButtonPressed(Input.GetMouseButton(0));

        if (m_mode == GunMode.UIPointer)
        {
            RaycastHit hit;
            if (Physics.Raycast(laserEmitterTransform.position, transform.forward, out hit))
            {
                m_laserDot.SetActive(true);
                m_laserDot.transform.position = hit.point;
                m_laserDot.transform.LookAt(laserEmitterTransform.position);
                m_lineRenderer.SetPositions(new Vector3[2] {
                    laserEmitterTransform.position, hit.point
                });
            }
            else
            {
                m_laserDot.SetActive(false);
                m_lineRenderer.SetPositions(new Vector3[2] {
                    laserEmitterTransform.position, laserEmitterTransform.position + transform.forward * 20
                });
            }

            if (VRInputManager.GetIsControllerButtonPressed())
            {
                m_lineRenderer.startColor = Color.green;
                m_lineRenderer.endColor   = Color.green;
            }
            else
            {
                m_lineRenderer.startColor = Color.red;
                m_lineRenderer.endColor   = Color.red;
            }
        }
        else
        {
            if (m_nextProjectileDelay > 0)
            {
                m_nextProjectileDelay -= Time.deltaTime;
            }
            if (VRInputManager.GetIsControllerButtonPressed())
            {
                if (m_nextProjectileDelay <= 0)
                {
                    GameObject projectile = Instantiate(GameManager.GetInstance().GetProjectileManager().paintBombPrefab, launcherTransform.position + launcherTransform.forward * 3, launcherTransform.rotation);
                    projectile.GetComponent <PaintProjectileBehavior>().paintColor = GameManager.GetInstance().GetProjectileManager().paintBombColor;
                    projectile.GetComponent <Rigidbody>().velocity = launcherTransform.forward * 20;
                    m_nextProjectileDelay = m_projectileDelay;
                }
            }

            if (Input.GetMouseButtonDown(1))
            {
                GameManager.GetInstance().GetProjectileManager().paintBombColor = c_colorArray[m_currColor];
                m_currColor++;
                if (m_currColor == c_colorArrayLength)
                {
                    m_currColor = 0;
                }
            }

            // TODO: DEBUG ONLY
            if (Input.GetMouseButtonDown(2))
            {
                GameManager.GetInstance().GetNpcManager().SpawnLandNpcAtRandom();
            }
            // DEBUG ONLY
        }
    }