Jump to content

lawwong

Employee
  • Posts

    10
  • Joined

  • Last visited

Reputation

3 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Yes, BasicGrabbable is derived from GrabbableBase, and is designed to be able to be easily overridden with customized grabbing condition. The abstract class "GrabbableBase" allows transform to track attached grabbers: - GrabbableBase.AddGrabber(grabber) : attach a grabber, then transform will keep tracking to the grabber's pose. Adding multiple grabbers is allowed, but only the last 1 or 2 added grabbers effect the tracking pose. - GrabbableBase.RemoveGrabber(grabber) : detach a grabber. - GrabbableBase.ClearGrabbers() : detach all grabbers. BasicGrabbable is only a shell that controls adding/removing grabbers whenever a grabber is close enough and demand button is pressed (ColliderEvent). Due to networking game often involves controlling and synchronizing who can move or who is moving the ball, you may need to either rewrite or override BasicGrabbable with some synced condition and network command, depends on your gameplay and the networking framework you are using.
  2. For VIU grabbables, there's a public event where you can modify velocity when ever it is dropped or released. I suggest you register BasicGrabbable.onDrop callback and multiply the velocity on BasicGrabbable.grabRigidbody.
  3. VIU is dedicated on identifying controller model for connected controller device VRModule.GetDeviceState(ViveRole.GetDeviceIndex(HandRole.RightHand)).deviceModel This property should tell you which device is currently used public enum VRModuleDeviceModel { // ... OculusTouchLeft, // Oculus 1 OculusTouchRight, // Oculus 1 // ... ViveFocusChirp, // Focus Plus // ... OculusQuestOrRiftSControllerLeft, // Oculus 2 OculusQuestOrRiftSControllerRight, // Oculus 2 // ... WaveCRControllerLeft, // Focus 3 WaveCRControllerRight, // Focus 3 // ... } (This maybe a good point that we may consider adding more HMD device model but only if there is a strong reason or strong request, in case you need to know the using device without any connected controller)
  4. Thanks for the feedback! Its seems to be a bug, will fix in next update. If need it, you can hot fix yourself by modifying following line https://github.com/ViveSoftware/ViveInputUtility-Unity/blob/baacdbd76387574b16efc0a5bcc430eebb258e3f/Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModule.cs#L334 into state.SetAxisValue(VRModuleRawAxis.TouchpadX, primary2DAxis.x); state.SetAxisValue(VRModuleRawAxis.TouchpadY, primary2DAxis.y); It seems odd but VRModuleRawAxis.TouchpadX/Y actually means "primary axis X/Y" now. (See how the field treated in ControllerState.cs if you are interested) Briefly, the weird naming was a legacy design issue.
  5. Hi @bella-1995, I'm guessing you get "raycastResults" from ViveRaycaster.SortedRaycastResults ? That means this property stores all raycast results and sorted by hit distance, hence index 0 result is the nearest. (Or just use ViveRaycaster.FirstRaycastResult() function) Default UGUI event, reticle and guideline all interact with only the first raycast result, you can do the same. Alternatively you can also implement your interaction logic within the event handlers. FYR., more details from Unity docs: https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/SupportedEvents.html
  6. Hi @AlGolden The unexpected behavior for you is caused by this: In our default setup in our prefab & example scene, RenderModelHook (visible controller model) will be switched off only if device is disconnected. ColliderEventCaster (invisible controller grabber) will be switched off if device is disconnected or lost tracking. So when your Rift controller or Vive controller lost tracking (but still connected), their model are still visible but the grabber is disabled (thus grabbed object is released). But for Focus Plus controller, its hard to lost its tracking, so the grabber isn't disabled. Assuming you want to align them, Option 1) Make RenderModelHook also switched off when device is disconnected or lost tracking by simply adding switch function to PoseTracker.OnIsValidChanged callback Option 2) Make CooliderEventCaster switched off only if device is disconnected To achieve that, you have to write a script that detect if device is connected (see attached file) DetectDeviceConnection.cs Hope it helps.
  7. Do you mean you want to rotate camera root around HMD? public static void RotateAroundHMD(Transform vrOrigin, Transform hmd, Quaternion rot) { vrOrigin.position = rot * (vrOrigin.position - hmd.position) + hmd.position; vrOrigin.rotation = rot * vrOrigin.rotation; } public static void OnSomeRightTurnEventOcurred() { // Turn right around Y axis for 45 degree RotateAroundHMD(vrOrigin, hmd, Quaternion.Euler(new Vector3(0f, 45f, 0f))); }
  8. Hi @FrancescoFontana About using Wave SDK via VIU, after you installed it into your project, first please make sure the Wave SDK support is enabled in the "Edit > Preferences > VIU Settings" configuration window. After that, you can take a look at the example scenes in HTC.UnityPlugin/ViveInputUtility/Examples folder. Briefly, the stereo camera is handled by the VIU script - VRCameraHook, so it can be crossed VR platforms.
  9. Its a historical issue... At first, ViveInput.GetPress only takes HandRole perameter. After the Role Binding Update, custom role enum is supported. I tried to add ViveInput.GetPress<TRole>(TRole role, ...) but the methods signature is ambiguous to ViveInput.GetPress(HandRole role, ...) because Unity was using older C# version. (template specialization only supported in newer C# version) It may not cause compile error if I just replace ViveInput.GetPress(HandRole role, ...) to ViveInput.GetPress<TRole>(TRole role, ...) but technically it changes the signature and also auto-completion for HandRole will be gone. (Considering developers will get panic when they don't know what TRole type should be)
  10. Hi, Following sample should do the work. Also it's cross platform. using HTC.UnityPlugin.Vive;using UnityEngine;public class SwipeSample : MonoBehaviour, IViveRoleComponent{ [serializeField] private ViveRoleProperty m_viveRole = ViveRoleProperty.New(HandRole.RightHand); [serializeField] private float m_swipeThreshold = 0.75f; private Vector2 m_downAxis; public ViveRoleProperty viveRole { get { return m_viveRole; } } private void OnEnable() { ViveInput.AddListener(m_viveRole, ControllerButton.PadTouch, ButtonEventType.Down, OnPadDown); ViveInput.AddListener(m_viveRole, ControllerButton.PadTouch, ButtonEventType.Up, OnPadUp); } private void OnDisable() { ViveInput.RemoveListener(m_viveRole, ControllerButton.PadTouch, ButtonEventType.Down, OnPadDown); ViveInput.RemoveListener(m_viveRole, ControllerButton.PadTouch, ButtonEventType.Up, OnPadUp); } private void OnPadDown() { m_downAxis = ViveInput.GetPadAxis(m_viveRole); } private void OnPadUp() { // get axis from last frame var upAxis = ViveInput.GetPadAxis(m_viveRole, true); var swipeVector = upAxis - m_downAxis; // skip if swipe distance is too short if (swipeVector.sqrMagnitude < m_swipeThreshold * m_swipeThreshold) { return; } // calculate direction var upScore = Vector2.Dot(swipeVector, Vector2.up); var downScore = Vector2.Dot(swipeVector, Vector2.down); var leftScore = Vector2.Dot(swipeVector, Vector2.left); var rightScore = Vector2.Dot(swipeVector, Vector2.right); var maxScore = Mathf.Max(upScore, downScore, leftScore, rightScore); if (maxScore == upScore) { Debug.Log("Swipe Up"); } else if (maxScore == downScore) { Debug.Log("Swipe Down"); } else if (maxScore == leftScore) { Debug.Log("Swipe left"); } else if (maxScore == rightScore) { Debug.Log("Swipe Right"); } }} No sure we are going to add this into API. Is it suitable for controller with joystick? (Oculus Touch, Vive Cosmos Controller) We have to consider what is the best threshold? How many directions should we use? 8 or 4 directions?
×
×
  • Create New...