Example #1
0
        void Start()
        {
            rb             = GetComponent <Rigidbody>();
            grabsInTrigger = GetComponent <GrabbablesInTrigger>();
            joint          = GetComponent <ConfigurableJoint>();
            input          = InputBridge.Instance;

            // Setup defaults
            if (joint == null)
            {
                joint = gameObject.AddComponent <ConfigurableJoint>();
                joint.rotationDriveMode = RotationDriveMode.Slerp;

                JointDrive slerpDrive = joint.slerpDrive;
                slerpDrive.positionSpring = 600;

                JointDrive xDrive = joint.xDrive;
                xDrive.positionSpring = 2500;
                JointDrive yDrive = joint.yDrive;
                yDrive.positionSpring = 2500;
                JointDrive zDrive = joint.zDrive;
                zDrive.positionSpring = 2500;
            }

            if (HandsGraphics)
            {
                handsGraphicsParent   = HandsGraphics.transform.parent;
                handsGraphicsPosition = HandsGraphics.transform.localPosition;
                handsGraphicsRotation = HandsGraphics.transform.localRotation;

                handsGraphicsGrabberOffset         = transform.InverseTransformPoint(HandsGraphics.position);
                handsGraphicsGrabberOffsetRotation = transform.localEulerAngles;
            }

            // Make Collision Dynamic so we don't miss any collisions
            if (rb && rb.isKinematic)
            {
                rb.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
            }

            // Should we auto equip an item
            if (EquipGrabbableOnStart != null)
            {
                GrabGrabbable(EquipGrabbableOnStart);
            }

            // Velocity Tracking
            if (velocityTracker == null)
            {
                velocityTracker = GetComponent <VelocityTracker>();
            }

            // Add Velocity Tracker if one was not provided
            if (velocityTracker == null)
            {
                velocityTracker = gameObject.AddComponent <VelocityTracker>();
                velocityTracker.controllerHand = HandSide;
            }
        }
Example #2
0
        // Start is called before the first frame update
        void Start()
        {
            transform.parent        = HandAnchor;
            transform.localPosition = Vector3.zero;
            transform.localRotation = Quaternion.identity;

            grabber = GetComponentInChildren <Grabber>();
            input   = GameObject.FindGameObjectWithTag("Player").GetComponent <InputBridge>();
        }
Example #3
0
        private void Awake()
        {
            grab = GetComponent <Grabbable>();

            if (GameObject.FindGameObjectWithTag("Player"))
            {
                input = GameObject.FindGameObjectWithTag("Player").GetComponent <InputBridge>();
            }
        }
Example #4
0
        // Start is called before the first frame update
        void Start()
        {
            transform.parent        = HandAnchor;
            transform.localPosition = Vector3.zero;
            transform.localRotation = Quaternion.identity;

            grabber = GetComponentInChildren <Grabber>();
            input   = InputBridge.Instance;
        }
Example #5
0
        // Start is called before the first frame update
        void Start()
        {
            input   = GetComponent <InputBridge>();
            uiPoint = GetComponentInChildren <UIPointer>();

            // Load new Hands. Default to White hands (3rd child child)
            if (LoadHandSelectionFromPrefs)
            {
                ChangeHandsModel(PlayerPrefs.GetInt("HandSelection", DefaultHandsModel), false);
            }
        }
Example #6
0
        // Start is called before the first frame update
        void Start()
        {
            originalFixedDelta = Time.fixedDeltaTime;
            if (SetFixedDelta)
            {
                originalFixedDelta = (Time.timeScale / UnityEngine.XR.XRDevice.refreshRate);
            }

            audioSource = GetComponent <AudioSource>();
            input       = GameObject.FindGameObjectWithTag("Player").GetComponent <InputBridge>();
        }
Example #7
0
        private void Awake()
        {
            // Destroy any duplicate instances that may have been created
            if (_instance != null && _instance != this)
            {
                Destroy(this);
                return;
            }

            _instance = this;

            DontDestroyOnLoad(gameObject);
        }
Example #8
0
        void Start()
        {
            rb             = GetComponent <Rigidbody>();
            grabsInTrigger = GetComponent <GrabbablesInTrigger>();
            joint          = GetComponent <ConfigurableJoint>();
            // Setup defaults
            if (joint == null)
            {
                joint = gameObject.AddComponent <ConfigurableJoint>();
                joint.rotationDriveMode = RotationDriveMode.Slerp;

                JointDrive slerpDrive = joint.slerpDrive;
                slerpDrive.positionSpring = 600;

                JointDrive xDrive = joint.xDrive;
                xDrive.positionSpring = 2500;
                JointDrive yDrive = joint.yDrive;
                yDrive.positionSpring = 2500;
                JointDrive zDrive = joint.zDrive;
                zDrive.positionSpring = 2500;
            }

            // Look for input from Player
            if (GameObject.FindGameObjectWithTag("Player"))
            {
                input = GameObject.FindGameObjectWithTag("Player").GetComponent <InputBridge>();
            }

            if (HandsGraphics)
            {
                handsGraphicsParent   = HandsGraphics.transform.parent;
                handsGraphicsPosition = HandsGraphics.transform.localPosition;
                handsGraphicsRotation = HandsGraphics.transform.localRotation;
            }

            playSpace                 = GameObject.Find("TrackingSpace");
            previousVelocities        = new List <Vector3>();
            previousAngularVelocities = new List <Vector3>();

            // Make Collision Dynamic so we don't miss any collisions
            if (rb && rb.isKinematic)
            {
                rb.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
            }

            // Should we auto equip an item
            if (EquipGrabbableOnStart != null)
            {
                GrabGrabbable(EquipGrabbableOnStart);
            }
        }
Example #9
0
        void Start()
        {
            if (GameObject.FindGameObjectWithTag("Player"))
            {
                input = GameObject.FindGameObjectWithTag("Player").GetComponent <InputBridge>();
            }

            grabClipArea = GetComponentInChildren <GrabberArea>();

            if (transform.parent != null)
            {
                parentWeapon = transform.parent.GetComponent <RaycastWeapon>();
            }
        }
Example #10
0
        void Start()
        {
            input    = GetComponent <InputBridge>();
            player   = GetComponent <BNGPlayerController>();
            teleport = GetComponent <PlayerTeleport>();

            // Load Locomotion Preference
            if (LoadLocomotionFromPrefs)
            {
                ChangeLocomotion(PlayerPrefs.GetInt("LocomotionSelection", 0) == 0 ? LocomotionType.Teleport : LocomotionType.SmoothLocomotion, false);
            }
            else
            {
                ChangeLocomotion(DefaultLocomotion, false);
            }
        }
Example #11
0
        // Start is called before the first frame update
        void Start()
        {
            input = GameObject.FindGameObjectWithTag("Player").GetComponent <InputBridge>();
            initialKnockPosition = ArrowKnock.localPosition;
            bowGrabbable         = GetComponent <Grabbable>();
            audioSource          = GetComponent <AudioSource>();

            // Define a few haptic positions
            drawDefs = new List <DrawDefinition>()
            {
                { new DrawDefinition()
                  {
                      DrawPercentage = 30f, HapticAmplitude = 0.1f, HapticFrequency = 0.1f
                  } },
                { new DrawDefinition()
                  {
                      DrawPercentage = 40f, HapticAmplitude = 0.1f, HapticFrequency = 0.1f
                  } },
                { new DrawDefinition()
                  {
                      DrawPercentage = 50f, HapticAmplitude = 0.1f, HapticFrequency = 0.1f
                  } },
                { new DrawDefinition()
                  {
                      DrawPercentage = 60f, HapticAmplitude = 0.1f, HapticFrequency = 0.1f
                  } },
                { new DrawDefinition()
                  {
                      DrawPercentage = 70f, HapticAmplitude = 0.1f, HapticFrequency = 0.1f
                  } },
                { new DrawDefinition()
                  {
                      DrawPercentage = 80f, HapticAmplitude = 0.1f, HapticFrequency = 0.1f
                  } },
                { new DrawDefinition()
                  {
                      DrawPercentage = 90f, HapticAmplitude = 0.1f, HapticFrequency = 0.9f
                  } },
                { new DrawDefinition()
                  {
                      DrawPercentage = 100f, HapticAmplitude = 0.1f, HapticFrequency = 1f
                  } },
            };
        }
Example #12
0
        void Awake()
        {
            col   = GetComponent <Collider>();
            rigid = GetComponent <Rigidbody>();

            if (GameObject.FindGameObjectWithTag("Player"))
            {
                input = GameObject.FindGameObjectWithTag("Player").GetComponent <InputBridge>();
            }
            else
            {
                Debug.LogError("No InputBridge Found on Player GameObject. Make sure you have one Player with the 'Player' Tag and the InputBridge component");
            }

            events     = GetComponents <GrabbableEvents>().ToList();
            collisions = new List <Collider>();

            // Try parent if no rigid found here
            if (rigid == null && transform.parent != null)
            {
                rigid = transform.parent.GetComponent <Rigidbody>();
            }

            // Store initial rigidbody properties so we can reset them later as needed
            if (rigid)
            {
                initialCollisionMode     = rigid.collisionDetectionMode;
                initialInterpolationMode = rigid.interpolation;
                wasKinematic             = rigid.isKinematic;
                usedGravity = rigid.useGravity;
            }

            // Store initial parent so we can reset later if needed
            UpdateOriginalParent(transform.parent);

            validGrabbers = new List <Grabber>();

            OriginalScale = transform.localScale.x;

            if (GameObject.FindGameObjectWithTag("Player"))
            {
                player = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <BNGPlayerController>();
            }
        }
Example #13
0
        void Start()
        {
            if (HandAnchor)
            {
                transform.parent = HandAnchor;

                if (ResetHandAnchorPosition)
                {
                    transform.localPosition = Vector3.zero;
                    transform.localRotation = Quaternion.identity;
                }
            }

            if (grabber == null)
            {
                grabber = GetComponentInChildren <Grabber>();
            }

            input = InputBridge.Instance;
        }
Example #14
0
        void Start()
        {
            rigid                  = GetComponent <Rigidbody>();
            offset                 = GetComponent <ControllerOffsetHelper>();
            offsetTransform        = new GameObject("OffsetHelper").transform;
            offsetTransform.parent = transform;

            if (HandAnchor)
            {
                transform.parent       = HandAnchor;
                offsetTransform.parent = HandAnchor;

                if (ResetHandAnchorPosition)
                {
                    transform.localPosition    = offsetPosition;
                    transform.localEulerAngles = offsetRotation;
                }
            }

            if (grabber == null)
            {
                grabber = GetComponentInChildren <Grabber>();
            }

            input = InputBridge.Instance;

            if (SmoothMovement && HandAnchor != null)
            {
                // Only change interpolation settings if no Rigidbody is found on this gameobject
                if (rigid == null)
                {
                    rigid               = gameObject.AddComponent <Rigidbody>();
                    rigid.isKinematic   = true;
                    rigid.interpolation = RigidbodyInterpolation.Interpolate;
                    rigid.useGravity    = false;
                }
            }
        }
Example #15
0
        private void Awake()
        {
            // Destroy any duplicate instances that may have been created
            if (_instance != null && _instance != this)
            {
                Destroy(this);
                return;
            }

            _instance = this;

#if UNITY_2019_3_OR_NEWER
            InputDevices.deviceConfigChanged += onDeviceChanged;
            InputDevices.deviceConnected     += onDeviceChanged;
            InputDevices.deviceDisconnected  += onDeviceChanged;
#endif

            // Update all device properties
            List <InputDevice> devices = new List <InputDevice>();
            InputDevices.GetDevices(devices);

            setDeviceProperties();
        }
Example #16
0
        void Start()
        {
            rigid                  = GetComponent <Rigidbody>();
            offset                 = GetComponent <ControllerOffsetHelper>();
            offsetTransform        = new GameObject("OffsetHelper").transform;
            offsetTransform.parent = transform;

            if (HandAnchor)
            {
                transform.parent       = HandAnchor;
                offsetTransform.parent = HandAnchor;

                if (ResetHandAnchorPosition)
                {
                    transform.localPosition    = offsetPosition;
                    transform.localEulerAngles = offsetRotation;
                }
            }

            if (grabber == null)
            {
                grabber = GetComponentInChildren <Grabber>();
            }

            // Subscribe to grab / release events
            if (grabber != null)
            {
                grabber.onAfterGrabEvent.AddListener(OnGrabberGrabbed);
                grabber.onReleaseEvent.AddListener(OnGrabberReleased);
            }

            // Try getting child animator
            SetHandAnimator();

            input = InputBridge.Instance;
        }
Example #17
0
 private void Awake()
 {
     grab  = GetComponent <Grabbable>();
     input = InputBridge.Instance;
 }
Example #18
0
        public override void OnInspectorGUI()
        {
            inputBridge = (InputBridge)target;

            setupRichText();

            EditorGUILayout.PropertyField(inputSource);

            // Show Action Set if using Unity Input
            // if (inputBridge.InputSource == XRInputSource.UnityInput) {
            EditorGUILayout.PropertyField(actionSet);
            // }

            // Tracking Origin
            EditorGUILayout.PropertyField(trackingOrigin);

            // Deadzone
            EditorGUILayout.PropertyField(ThumbstickDeadzoneX);
            EditorGUILayout.PropertyField(ThumbstickDeadzoneY);

            EditorGUILayout.Separator();

            // Currently showing all
            if (inputBridge.ShowInputDebugger)
            {
                // Button to Hide all
                if (GUILayout.Button("Hide Input Debugger"))
                {
                    inputBridge.ShowInputDebugger = false;
                }

                // Show each item
                EditorGUILayout.Separator();

                EditorGUILayout.LabelField("Input Debugger : ", bold);

                DrawLabel("A Button", inputBridge.AButton);
                DrawLabel("B Button", inputBridge.BButton);
                DrawLabel("X Button", inputBridge.XButton);
                DrawLabel("Y Button", inputBridge.YButton);
                DrawLabel("Start Button", inputBridge.StartButton);
                DrawLabel("Back Button", inputBridge.BackButton);

                DrawLabelFloat("Left Trigger", inputBridge.LeftTrigger);
                DrawLabelFloat("Right Trigger", inputBridge.RightTrigger);


                DrawLabelFloat("Left Grip", inputBridge.LeftGrip);
                DrawLabelFloat("Right Grip", inputBridge.RightGrip);

                DrawLabel("Left Trigger Near", inputBridge.LeftTriggerNear);
                DrawLabel("Right Trigger Near", inputBridge.RightTriggerNear);

                DrawLabel("Left Thumb Near", inputBridge.LeftThumbNear);
                DrawLabel("Right Thumb Near", inputBridge.RightThumbNear);

                DrawLabelVector2("Left Thumbstick  ", inputBridge.LeftThumbstickAxis);
                DrawLabelVector2("Right Thumbstick", inputBridge.RightThumbstickAxis);

                // Thumb / Index Touching

                DrawLabelVector2("Left TouchPad Axis  ", inputBridge.LeftTouchPadAxis);
                DrawLabelVector2("Right TouchPad Axis", inputBridge.RightTouchPadAxis);

                EditorGUILayout.Separator();

                EditorGUILayout.LabelField("Device Properties : ", bold);

                DrawLabel("HMD Active", inputBridge.HMDActive);

                string deviceName = inputBridge.GetHMDName();
                if (!string.IsNullOrEmpty(deviceName))
                {
                    EditorGUILayout.LabelField("Device Name : <color=green><b>" + deviceName + "</b></color>", rt);
                }
                else
                {
                    EditorGUILayout.LabelField("Device Name : <color=gray><b>(Undetected)</b></color>", rt);
                }

                string controllerName = inputBridge.GetControllerName();
                if (!string.IsNullOrEmpty(controllerName))
                {
                    EditorGUILayout.LabelField("Controller Name : <color=green><b>" + controllerName + "</b></color>", rt);
                }
                else
                {
                    EditorGUILayout.LabelField("Controller Name : <color=gray><b>(Undetected)</b></color>", rt);
                }
            }
            // Hiding input debugger
            else
            {
                if (GUILayout.Button("Show Input Debugger"))
                {
                    inputBridge.ShowInputDebugger = true;
                }
            }

            // Apply any changes
            serializedObject.ApplyModifiedProperties();
        }
Example #19
0
 void Start()
 {
     input = GetComponent <InputBridge>();
 }
Example #20
0
 protected virtual void Awake()
 {
     grab  = GetComponent <Grabbable>();
     input = InputBridge.Instance;
 }