Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[RELEASED] VR Interaction Framework

Discussion in 'Assets and Asset Store' started by BeardedNinjaGames, Jan 28, 2020.

  1. adamz

    adamz

    Joined:
    Jul 18, 2007
    Posts:
    1,031
    Thanks, I just gave it a try. The problem is that it scales the player, so when the scene starts and you stand you're the correct height. As soon as you sit and press "A", the player is scaled down and the world is too large. I think its a good idea for different seating heights. Is there an easy way to scale the word too based on how you have it set up?

    +1 for implementing two handed weapons using Final IK!

    Keep up the good work! I gave you a decent review on the Asset Store too. :)

    UPDATE
    Also when I press the "A" button while sitting the elbow joints don't scale properly either. The bend is not the same as when standing.
     
    Last edited: Apr 16, 2020
    BeardedNinjaGames likes this.
  2. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    This is probably a stupid easy question, but what the heck.. with the XR framework, how the HECK do I recenter my HMD???

    https://docs.unity3d.com/ScriptReference/XR.InputTracking.Recenter.html

    This is obsolete now...

    and...

    https://docs.unity3d.com/ScriptReference/XR.XRInputSubsystem.TryRecenter.html

    How the heck does this work?

    I tried something like..

    Code (CSharp):
    1.  
    2.         List<XRInputSubsystem> subsystems = new List<XRInputSubsystem>();
    3.         SubsystemManager.GetInstances<XRInputSubsystem>(subsystems);
    4.         Debug.Log("subsystems.Count: "+subsystems.Count);
    5.         for (int i = 0; i < subsystems.Count; i++)
    6.         {
    7.             Debug.Log(subsystems[i].SubsystemDescriptor);
    8.             subsystems[i].TrySetTrackingOriginMode(TrackingOriginModeFlags.Floor);
    9.             bool test = subsystems[i].TryRecenter();
    10.             Debug.Log("Recentering HMD: "+test);
    11.         }
    12.  
    But that doesn't do anything. A clue is that subsystems.Count returns ZERO. So why isn't it finding the subsystem? And why is this so damn convoluted?

    If I switch to Oculus Dash and Reset View there, then it resets to where I'm looking. I want to do that when the game starts!

    I'm actually hoping the VR Interaction Framework just has a helper function built in to simply do this for me so I don't need this boilerplate nonsense in my main script??

    Thanks!!
     
    Last edited: Apr 17, 2020
  3. Muskie

    Muskie

    Joined:
    Jan 21, 2017
    Posts:
    27
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.XR;
    5.  
    6. /// <summary>
    7. /// Recenters the Player in the VR space.
    8. /// </summary>
    9. public class RecenterPlayer : MonoBehaviour
    10. {
    11.  
    12.     public void Recenter()
    13.     {
    14.  
    15.      
    16.         List<XRInputSubsystem> subsystems = new List<XRInputSubsystem>(); //declare the subsystem list
    17.         SubsystemManager.GetInstances<XRInputSubsystem>(subsystems); // get the available XR input subsystems
    18.  
    19.         //Recenter all available subsystems
    20.         for (int i = 0; i < subsystems.Count; i++)
    21.         {
    22.             subsystems[i].TryRecenter();
    23.         }
    24.      
    25.     }
    26. }
    27.  
    just a note: this works only on Rift/Vive and the like. Oculus specifically note that the player should be using the universal menu to recenter on Quest.
     
  4. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    Thanks for the reply!

    Hmm, your code is almost identical to my code. My main issue, I think, is that "subsystems.Count" is ZERO. Why isn't unity finding any subsystems, like it probably should?
     
  5. serenaaliu

    serenaaliu

    Joined:
    Mar 26, 2020
    Posts:
    1
    How to detect the object is being grabbed and trigger animation
     
  6. CHACHINOI

    CHACHINOI

    Joined:
    Aug 21, 2019
    Posts:
    2
    hello, i saw that you were going to integrate pun2 in version 1.5, can you tell me how soon about?
     
  7. BeardedNinjaGames

    BeardedNinjaGames

    Joined:
    Jan 26, 2020
    Posts:
    125
    Are you on 2019.2 or 2019.3? I'm not sure why this would be returning 0 for you. What device are you running this on? If you're targeting an Oculus device maybe you can use one of the OVR methods.

    If you're looking to trigger an animation on the hand, you can set a HandPose on the Grabbable which will set a PoseID on the hand Animator. If you mean on the object when it's grabbed, you can use the "OnGrab" GrabbableEvent.

    I am currently working on that, but can't really give an ETA at the moment. If you're looking to integrate it yourself, I can at least give you a suggestion - don't network instantiate the player, but instead use a "NetworkManager" that acts as a proxy for the remote players. This grabs the information from the player (hand/head position / rotation, grab state, etc.) and sends that information to the other players. This way you don't have to disable a bunch of components on the Player object or write conditional all over the place.
     
  8. Chachinoi33

    Chachinoi33

    Joined:
    Apr 20, 2015
    Posts:
    6
    ok thank you, i will wait considering the good work you have already done it will be better done than me;)
     
  9. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    2019.3, Oculus Rift

    What would the OVR way be? It'd be super handy if this could just be part of a utility inside VRF
     
  10. LaCorbiere

    LaCorbiere

    Joined:
    Nov 11, 2018
    Posts:
    18
    Hello. Just messing around with an animated enemy and a shotgun. What would be the best way to implement the damageable script to a rigged animated bipedal character that would take damage from the Raycast Weapon Script? Thank you.
     
  11. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    Btw, figured it out. I didn't have the subsystems package installed! What the... Lol

    That being said, is it just me or is it INSANE that the new XR Management only has Multipass (which is slow) and Single Pass Instanced (which few assets are compatible with)
     
  12. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,976
    Isn't that all Unity's ever supported?
     
  13. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    Nope, Single Pass (not instanced) is widely supported
     
  14. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,976
    Oh, I gotcha. I've never bothered with anything other than Single Pass Instanced because of the performance boost. I don't mess with custom shaders, either, though. It would be nice if Unity had more guidance for adapting shaders to work with SPI, but that's certainly a topic for a different thread.
     
  15. BeardedNinjaGames

    BeardedNinjaGames

    Joined:
    Jan 26, 2020
    Posts:
    125
    Hi everyone,

    Version 1.31 has been submitted - here are the notes :
    1. Better hand snap support on all objects using SnapPoints. Try grabbing the rifle with a handle / grip to see the various grab point angles that have been provided. You can also use SnapPoints on object thats don't move towards the hand, such as doors and knobs. Check out the door with a handle and the first snapping knob example to see how the hand snaps in place.
    2. Added 2 Knob / Dial examples. One that snaps to a specific increment (in the demo 10 degrees). This also plays a bit of haptics and an audioclip that slightly varies it's pitch. I find it to be a particularly satisfying interaction, and with a hand animation would be even better (more on that later). You can also let the dial rotate freely, customize friction, etc.
    3. Added fingerless gloves textures (I may have been playing a bit of HL:A lately :p

    4. The InputBridge is now a Singleton for easier access (no more FindWithTag()!).
    5. Experimental SteamVR integration package. There is an included integration package that provides SteamVR actions / bindings that the InputBridge can now read. Be sure to read the included Readme.
    6. Added a SnapZoneScale component. Similar to SnapZoneOffset, you can use this to customize / override the scale of an object when in a snap zone.
    7. Added GrabbableHighlightMaterial script. The Oculus soccer ball on the table uses a different material when eligible for pickup / remote grab. This is a good way to handle a highlight effect without a high performance cost.
    8. New component "ReturnToSnapPoint" allows a Grabbable to always return to a snap point if not being held.
    9. Can now initiate Teleport from either right or left hand (thanks to @BrennanHatton for code submission)
    10. Fixed issue with angular velocity being off if tracking space was changed
    11. Various bug fixes regarding player needing to be positioned at 0,0,0 on level start and UnityEvents.
     
    jashan and Schneider21 like this.
  16. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,976
    Wow. I am so glad I bought this asset. Great work, and fantastic updates!

    Really looking forward to PUN integration. I have multiple headsets, so let me know if you need beta testers when you get to that point. :p
     
    BeardedNinjaGames likes this.
  17. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,248
    AWESOME!!! :)
     
  18. BeardedNinjaGames

    BeardedNinjaGames

    Joined:
    Jan 26, 2020
    Posts:
    125
    Hi everyone,

    I just submitted v1.32 to the asset store. The previous version (1.31) was submitted using a 2018.4 version of Unity, which was causing some installation issues with the package manager. This version uses 2019.3 to maintain better support. If you need a version for 2018.4 please contact me on Discord and I can send you a link.

    In addition to a smoother installation, there are a few additional features and bug fixes :

    1. Included an additional set of high quality hand models. I really think having a nice pair of hands is important for VR / immersiveness, so I went ahead and had a go at texturing the Oculus hands. I also added an additional glove mesh which I think looks quite nice. The hand textures can be improved upon, but I think it's a good start!

    Since these are based off of the Oculus hands, all of your animations / poses will automatically work with these. I'm considering making a hands pack with additional textures / variations - so let me know if that's something you're interested in!




    2. Included a basic Photon PUN multiplayer example (found in /integrations/PUN/). Quite a few people have asked how I would go about setting up multiplayer for VR, so here it is! There is a NetworkManager component that connects to a specified room, and a NetworkPlayer components that syncs the player's head, hands, and hand animations. Nothing else is networked, but I think this is a great place to start if you're looking to create a multiplayer game. I spent quite a bit of time tweaking the interpolation and I think it feels really good so far.

    3. Fixed issue with not being able to fire arrows that were manually picked up.

    4. Bow damage is no longer hardcoded and will retrieve damage value from the projectile component if it is available

    5. Fixed issue with World Space Debug window not scrolling properly

    6. Added option to GrabbableHaptics to vibrate on grab. May be particularly useful for Climbable objects.
     
    Schneider21 likes this.
  19. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    880
    I am. A LOT.
    But it should be high quality textures with normal maps and full hand leather gloves.
     
    BeardedNinjaGames likes this.
  20. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,976
    Listen, man. As someone who creates assets also, you're giving the rest of us a bad name. Last word on this was "sometime in the future", and now here it is! :p

    That sounds good. As a person who can make basic models and make changes to existing ones in Blender, I'd appreciate any tips or guidance you can give on making these hand models that work with the Oculus integration. I took a stab at it before, and maybe I had the skinning wrong or something, because what I made was the stuff of nightmares.

    - - -

    Thanks for the great update! Keep 'em coming!
     
    BeardedNinjaGames likes this.
  21. remiC3D

    remiC3D

    Joined:
    Dec 15, 2017
    Posts:
    26
    Hello,

    I'm entirely new to this asset, and I must say I find it quite fantastic !
    I'm however facing a small issue right away when testing the demo scene (after following the installation instructions from the documentation, and without changing anything else) :
    There seem to be an issue with the way the arm IK is solved on the elbows : this is what I get when running the demo scene :
    upload_2020-5-7_23-55-16.png
    As you can see my virtual elbows seem kind of "inverted", which makes me feel like a giant insect or something :)
    I tried searching the documentation and this forum, for this issue, but to no avail...
    I also tried checking/unchecking these options on the PlayerAdvanced Variant/BodyIK game object :
    upload_2020-5-8_0-0-13.png
    But it doesn't seem they have any impact on the way the Ik is solved... In fact, even checking the "hide left/right arm/hand" doesnt seem to actually hide the arms or the hands, or impact the IK behaviour...

    What am I missing ?

    My setup :
    - Unity 2019.3
    - VR Interation Framework Version 1.32
    - Oculus Integration 12.0
    - Oculus Quest controllers
    - Using Oculus Quest headset but in Oculus Link mode
    - So target Platform is "PC, Mc & Linux Standalone"
    - Using Oculus SDK in XR settings

    Thanks in advance for your help !
     
    Last edited: May 7, 2020
  22. Starmind01

    Starmind01

    Joined:
    May 23, 2019
    Posts:
    66
    Quick question, How do you turn off gravity? I tried to turn it off in the bngcontroller and the ovrcontroller on trigger enter, but it was a no go. What I am trying to do is trigger a zero g area where the player can grab, but not fall. The only thing I seem to have done is make the gravity multiplier = zero. I modified the hand jet script only for the gravity the rest is commented out.
    Silly question I know, but I real want a zero g trigger and any help would be great!
     
  23. BeardedNinjaGames

    BeardedNinjaGames

    Joined:
    Jan 26, 2020
    Posts:
    125
    That is an odd one. I've seen that happen when using the SteamVR SDK - do you have that installed? Removing that (and keeping OpenVR) should fix it. The "Hide Head" and other IK settings are mostly about hiding the bones (by scaling them to a very small value) and shouldn't necessarily affect the IK positions. The character IK is setup so that there is a character model hooked up with IK to the controllers / hand positions. That character is then hidden, and our hands / arms work backwards, pointing at the hidden joints. There is some more info on why that is setup that way here, if you're interested.

    There is a public function in BNGController you can use to toggle gravity : public void UpdateGravity(bool gravityOn) {

    That will prevent your character from falling (it's basically setting the gravity modifier on the OVRPlayerController to 0 every frame), but may not function quite how you want it to, since the player uses a Unity CharacterController and is affected differently by Gravity. I am working on a Rigidbody character that would handle this better, but it will be a little while before that is ready.
     
  24. remiC3D

    remiC3D

    Joined:
    Dec 15, 2017
    Posts:
    26
    Thanks a lot for your answer, it was indeed the case, as i'm trying to migrate this project from SteamVR SDK to yours.

    Any idea on which specific SteamVR feature/script may be causing this ? Removing them all did fix the issue, but I would like to progressively migrate my project, so removing them all in one go forces me to also remove all my own classes (that references steamVR's ones), which isn't the most convenient solution for me...
     
  25. Muskie

    Muskie

    Joined:
    Jan 21, 2017
    Posts:
    27
    Hey, would it be possible to get a quick rundown/tutorial on making those handles and knobs added in the last update? They look great and are one of the things that got me looking at the project, but I can't for the life of me figure out how all these joint systems work... I've never really done much with physics in Unity (I Know, I know, then why am I making a VR game?!)
     
  26. Starmind01

    Starmind01

    Joined:
    May 23, 2019
    Posts:
    66
    I am looking forward to the new controller! Will you have zero g movement?
     
  27. Muskie

    Muskie

    Joined:
    Jan 21, 2017
    Posts:
    27
    If you're after a Zero G area for physics/Rigidbodies, Add this to objects you want to be in Zero-G:


    [
    Code (CSharp):
    1. public class ZeroGChecker : MonoBehaviour
    2. {
    3.     public bool isZeroG;
    4.     Rigidbody rb;
    5.  
    6.     private void Start()
    7.     {
    8.         rb = GetComponent<Rigidbody>();
    9.     }
    10.  
    11.     private void FixedUpdate()
    12.     {
    13.         CheckZeroG();
    14.     }
    15.  
    16.     private void CheckZeroG()
    17.     {
    18.         if (isZeroG)
    19.         {
    20.            rb.AddForce(-Physics.gravity); //adds force inverse to unity's current gravity value (thanks atomicjoe!)
    21.         }
    22.  
    23.     }
    24. }
    Then make an object with a box collider, set it to Trigger, edit the collider to be the area you want to have Zero G enabled, and put this script on it:


    Code (CSharp):
    1. public class ZeroGVolume : MonoBehaviour
    2. {
    3.  
    4.  
    5.     private void OnTriggerEnter(Collider other)
    6.     {
    7.         if (other.GetComponent<ZeroGChecker>())
    8.         {
    9.             other.GetComponent<ZeroGChecker>().isZeroG = true;
    10.         }
    11.     }
    12.  
    13.     private void OnTriggerExit(Collider other)
    14.     {
    15.         if (other.GetComponent<ZeroGChecker>())
    16.         {
    17.             other.GetComponent<ZeroGChecker>().isZeroG = false;
    18.         }
    19.     }
    20. }
    Now any rigidbody that enters the trigger volume will have Zero Gravity (technically they'll just have upwards force added to them to counteract gravity at all times).

    feel free to play around with this, you could do really stupid stuff like jetpacks, microgravity, and even straight up VVVVVV gravity flipping!
     
    Last edited: May 10, 2020
  28. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    880
    Hey you're not alone on this one! :D
    Time to RTFM now!
     
  29. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    880
    You know there is a physics property you can use for that, right? :p
    https://docs.unity3d.com/ScriptReference/Physics-gravity.html

    Code (CSharp):
    1. rb.AddForce(-Physics.gravity);
     
  30. superjayman

    superjayman

    Joined:
    May 31, 2013
    Posts:
    185
    Why can't I use the child-object colliders for picking up?? At the moment you are putting multiple colliders to grabbable object which are not even aligned properly.

    THIS IS A DEAL BREAKER!! It makes it a pain and/or impossible to place accurate colliders. When will you support compound shapes? You should at least provide a mechanism where we can explicitly assign a list of child colliders or something. At the moment even doing a simple table where you can pick it up from any leg is a pain to setup as you have to add the box-colliders to grabbable (You can't even rotate the box colliders)
     
  31. Muskie

    Muskie

    Joined:
    Jan 21, 2017
    Posts:
    27
    atomicjoe likes this.
  32. Starmind01

    Starmind01

    Joined:
    May 23, 2019
    Posts:
    66
    I do know how to do that. My question was meant more for the character controller than rigidbodies. I was having a problem turning off gravity as it seemed to be in 3 different places. That is why BNG wrote this below:

     
  33. Starmind01

    Starmind01

    Joined:
    May 23, 2019
    Posts:
    66
    So I am able to get the player gravity to turn off now, but the character controller or the bng controller is fighting the movement. I was looking at the handjet script, but I cannot seem to add the movement base on the push off of the grab point.Like I said before, the character controller stop the movement.
    My lastest thought was to add a rigidbody and have it kinematic and add force like swimming. That was not a pleasant experience in vr. I know that the character controller can do swimming, but it is not working now. Don't know why. Swimming and zero g are similar in movement with the exception of drag.

    Below is the script for turning off gravity in a trigger and a video what it currently looks like.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. namespace BNG
    6. {
    7.     public class ZeroG : MonoBehaviour
    8.     {
    9.         BNGPlayerController bngController;
    10.  
    11.         public bool GravityEnabled = true;
    12.  
    13.         private void Start()
    14.         {
    15.             bngController = GameObject.FindGameObjectWithTag("Player").GetComponent<BNGPlayerController>();
    16.         }
    17.         void OnTriggerEnter(Collider other)
    18.         {
    19.             if (other.GetComponent<CharacterController>())
    20.             {
    21.                 ChangeGravity(false);
    22.             }
    23.         }
    24.  
    25.         public void ChangeGravity(bool gravityOn)
    26.         {
    27.             GravityEnabled = gravityOn;
    28.             bngController.GravityEnabled = gravityOn;
    29.         }
    30.  
    31.         void OnTriggerExit(Collider other)
    32.         {
    33.             if (other.GetComponent<CharacterController>())
    34.             {
    35.                 ChangeGravity(true);
    36.             }
    37.         }
    38.     }
    39. }
    40.  
     
  34. Starmind01

    Starmind01

    Joined:
    May 23, 2019
    Posts:
    66
    After a little tinkering, I am able to get objects that are thrown into the area to react to the zero g, but not the player. Pretty much at the mercy of the character controller. I tried to use an old script for swimming, but it doesn't work.

    I did find a really cool effect with bullet time/ slow mo. Just had to share.


    You can see some effect on the player as I enter the zero g area. I go straight up on entering. Here is my current script below. If anyone knows how to fix the movement in zero g, that would be great. I have some distractions at the moment keeping me from seeing my errors.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. namespace BNG
    6. {
    7.     public class ZeroG : MonoBehaviour
    8.     {
    9.         OVRPlayerController pControl;
    10.         BNGPlayerController bngController;
    11.         Vector3 moveVector;
    12.         public float speed;
    13.  
    14.         public bool GravityEnabled = true;
    15.         private Vector3 moveDirection = Vector3.zero;
    16.         private float _initialGravityModifier;
    17.  
    18.         private void Start()
    19.         {
    20.             pControl = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren<OVRPlayerController>();
    21.             bngController = GameObject.FindGameObjectWithTag("Player").GetComponent<BNGPlayerController>();
    22.             _initialGravityModifier = pControl.GravityModifier;
    23.             moveVector = Vector3.zero;
    24.         }
    25.         void OnTriggerEnter(Collider other)
    26.         {
    27.             moveVector += Physics.gravity;
    28.             if (other.GetComponent<CharacterController>())
    29.             {
    30.                 ChangeGravity(false);
    31.                 other.GetComponent<CharacterController>().Move(moveVector * Time.deltaTime * speed);
    32.  
    33.             }
    34.             if (other.GetComponent<Rigidbody>())
    35.             {
    36.                 other.attachedRigidbody.useGravity = false;
    37.  
    38.             }
    39.         }
    40.  
    41.         public void ChangeGravity(bool gravityOn)
    42.         {
    43.             GravityEnabled = gravityOn;
    44.             bngController.GravityEnabled = gravityOn;
    45.         }
    46.  
    47.         void OnTriggerExit(Collider other)
    48.         {
    49.             moveVector = Vector3.zero;
    50.  
    51.             if (other.GetComponent<CharacterController>())
    52.             {
    53.                 ChangeGravity(true);
    54.             }
    55.  
    56.             if (other.GetComponent<Rigidbody>())
    57.             {
    58.                 other.attachedRigidbody.useGravity = true;
    59.  
    60.             }
    61.         }
    62.     }
    63. }
    64.  
     
  35. BeardedNinjaGames

    BeardedNinjaGames

    Joined:
    Jan 26, 2020
    Posts:
    125
    I've found the Oculus hand models have some issues that crop up once you start texturing them, especially once you add normal maps. I'd recommend creating a mesh over the hands, similar to how the glove was made (included in the latest version). Then you can delete the hand mesh / pieces you aren't using.

    Yes, definitely. I reworked how the Levers work, so wanted to hold off on making any videos / tutorials on that until I was happy with their mechanics. Levers are feeling really good now (more info on that below).

    This is by design / intentional. You should use compound, primitive colliders (box and sphere tend to work best) to approximate the general shape of the grabbable part of the object. Additional colliders for collision can be added as child colliders.

    If you have colliders as a child that you want to use in your parent, just copy / paste the collider component to the root object. You can also use GrabbableEvents to grab the parent Grabbable or use a GrabAction. Lastly, make sure your scales are 1,1,1 (or at the very least uniform). Be careful scaling / rotating child colliders as this can have a significant performance cost on the physics engine.

    The Unity CharacterController doesn't use a RigidBody and isn't affected by outside forces in the usual way. It's movement is updated on a per frame basis, by using .Move() or .SimpleMove(). You can simulate velocity by storing a value in a Vector3, and applying that to value to the CharacterController by calling .Move in Update().

    CharacterControllers work best if you need very precise movement, which is great for VR, but it is more difficult to manage things like velocity. RigidBody characters can handle things like velocity really well (it's built-in), but they are not as precise and have their own drawbacks as well. I favor the RigidBody approach, but I think the RigidBody character requires some extra care to make sure we don't accidentally make our users sick through involuntary movement.
     
  36. BeardedNinjaGames

    BeardedNinjaGames

    Joined:
    Jan 26, 2020
    Posts:
    125
    I also wanted to mention that I have reworked the levers quite a bit and am working to release the new mechanics as an update soon. I'm quite please with their overall feel. I would like to include a couple of additional prefab examples as well.

    (Switch models courtesy of @BATTLEKOT !) :



    There have been quite a few people wanting to use the player and / or levers on a moving platform or vehicle, so I am experimenting with being able to have these levers work on moving platforms as well. This would be through an option on the lever that would set its RigidBody to kinematic while it's not being held, in order to prevent the lever from being affected by the platform / vehicle's forces.

    I am also working on improving the GrabPoint system, as well as a tool to help align those Hand Poses up. I've found this to be quite.. handy :rolleyes:


    There is of course more in the works, but these are the two primary features planned for the next update.
     
    Last edited: May 10, 2020
    Mark_01, rayBLASTER, remiC3D and 3 others like this.
  37. Muskie

    Muskie

    Joined:
    Jan 21, 2017
    Posts:
    27
    This looks great! can't wait to use this, as this is exactly the kind of stuff i'm having trouble with atm.. while I managed to get a lever to stop moving with a quick kinematic switch like you said, buttons on the other hand... well...



    *hits play*



    So, uhh.. the quicker you get those out the better? lol (but seriously, thanks!)
     
  38. Starmind01

    Starmind01

    Joined:
    May 23, 2019
    Posts:
    66
    Thank you! But for me that is not much help at the moment. Basically using the demo area to test things I want for my game. Everything you have works great, except no zero g at the moment. Since I currently have all I need to continue with the beginning of my game, perhaps you will have zero g in a later update.

    If anyone is interested in playing this on the Oculus Quest here is the .apk to sideload.
     
  39. superjayman

    superjayman

    Joined:
    May 31, 2013
    Posts:
    185
    What are you on about, design/intentional?(Or don't know how to do it?) This is a major flaw to this system, I can't even do a simple tire to pickup. YOU CAN'T JUST COPY AND PASTE THE COLLIDER FROM CHILD!! Scales will be messed up plus other issues.

    Tell me how you would set up a table with 4 legs to be picked up, where one of the legs is on a 45 degree angle, you expect to put bunch of approximate boxes??

    I think of hundreds of other simple examples, where your current implementation actually forces you to break the 1,1,1 scale.

    Look at your bow example, you have pickup collision boxes in mid air not even intersecting with the bow. You couldn't even approximate the curvature of the bow!.. When you pickup a Rigid-Body all of its relevant colliders should be used child or not. You can at least do it so we can assign collider list.
     
  40. Muskie

    Muskie

    Joined:
    Jan 21, 2017
    Posts:
    27
    Colliders in unity ARE annoying yes, but it's no use getting so angry at the developer. Might I suggest the Technie Collider Creator to assist? I've used it for about 2 years now and I'm wondering why unity haven't acquired it for themselves like they did TextMeshPro and ProGrids. https://assetstore.unity.com/packages/tools/level-design/technie-collider-creator-62628
     
    Schneider21 and remiC3D like this.
  41. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    880
    Doesn't this create compound colliders? If that's the case, the problem would be the same, doesn't it?
     
  42. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    89
    @superjayman you might get more help if you weren't so rude. It's funny to me that you are obviously here because you don't have the talent to do any of this stuff yourself, but your tactic for getting help is by insulting the guy who does have that talent. Great job with the reverse-psychology here, implying he doesn't know what he's doing.
     
    StevenPicard, remiC3D and atomicjoe like this.
  43. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    880
    I agree but I think it's just frustration turning into anger.
     
  44. BeardedNinjaGames

    BeardedNinjaGames

    Joined:
    Jan 26, 2020
    Posts:
    125
    There is no need for this type of behavior, especially in a public forum. If you want to vent your frustrations then feel free to message me personally. Comments like this aren't going further your case, they are just going to cause me to become frustrated and not be able to respond appropriately. I am more than happy to explain to you why this is built this way, but you do not appear to want to listen to what I have to say. I have posted one way to fix the issue you described via GrabbableEvents below, as I had mentioned before in my previous post.

    Compound Colliders can be used on the same Grabbable (and is how I recommend doing it).You can use a tool like this to remove some of the pain of having to manually place box colliders on your object. You can of course just use a mesh collider if it makes sense to. For the tire example superjayman mentioned, a low poly mesh collider would probably be the best choice. If you were doing something with harder edges, such as a window / sill, then using a couple of simple box colliders on the same object will give you better performance than using a single mesh collider.

    Child colliders on the other hand are not automatically supported as part of the grabbable collider (you can still use them for collision). This is to prevent / discourage transform shearing, scaling issues, general performance (avoiding GetComponentsInChildren<> calls in every frame), and also makes it easier to support nested Grabbables.

    I will look into a performance-friendly way of supporting this more natively in the framework in the future. I have a few ideas on how this can be done. I am currently working on improving GrabPoints, so this could be a good place to support this type of feature.

    For now, you can use GrabbableEvents to simply grab a specified object. The idea is to immediately drop the object we just grabbed (as grabbing a child collider of a rigidbody will cause unwanted physics behaviour) and instead grab the specified Grabbable :

    Code (CSharp):
    1. public override void OnGrab(Grabber grabber) {
    2.  
    3.     base.OnGrab(grabber);
    4.  
    5.     // Never hold this item, it's just a proxy
    6.     grab.DropItem(grabber, false, false);
    7.  
    8.     // Don't grab this if we are currently holding something
    9.     if (grabber.RemoteGrabbingItem || grabber.HoldingItem) {
    10.        return;
    11.     }
    12.  
    13.     // Grab the Parent Grabbable instead
    14.     if (ParentGrabbable != null && !ParentGrabbable.BeingHeld) {
    15.         grabber.GrabGrabbable(ParentGrabbable);
    16.     }
    17. }
    Just attach the included script to the child collider you want to grab, assign the ParentGrabbable property, and you should be good to go :

     

    Attached Files:

  45. Muskie

    Muskie

    Joined:
    Jan 21, 2017
    Posts:
    27
    Hey, I'm trying to make a dispenser system using the Snap Points.

    What would be the best way to have a snap point start with a certain object snapped, and when the player detaches an object from the snap zone, a new clone of the object is instantiated and snapped to it?

    This is what I currently have:

    Code (CSharp):
    1. public class Dispenser : MonoBehaviour
    2. {
    3.     public GameObject dispenserPrefab;
    4.  
    5.  
    6.     public void Dispense()
    7.     {
    8.         VRUtils.Instance.Log("Dispensing Cup.");
    9.         GameObject newCup = Instantiate(dispenserPrefab, transform.position, Quaternion.identity) as GameObject;
    10.         newCup.transform.localScale = Vector3.one; //Set the object scale because for some reason the new object is scaled to 0,0,0 when instantiated
    11.        
    12.     }
    13. }
    Dispense() is assigned to the Detatch Event.

    It creates the new object, but the new object doesn't auto-snap to the snap point.
     
  46. BeardedNinjaGames

    BeardedNinjaGames

    Joined:
    Jan 26, 2020
    Posts:
    125
    Since you're really only ever removing an object from the SnapZone, you don't really need to use a SnapZone at all. You can just create an object on grab and make the grabber grab that.

    Try this : On the snapzone object, replace the "GrabAction" event from "SnapZone.GrabEquipped" to now just call your dispense function. That function can look like this :

    Code (CSharp):
    1. public class Dispenser : MonoBehaviour {
    2.  
    3.     public GameObject DispenserPrefab;
    4.  
    5.     public void Dispense(Grabber grabber) {
    6.         VRUtils.Instance.Log("Dispensing Cup.");
    7.  
    8.         GameObject newCup = Instantiate(DispenserPrefab, transform.position, Quaternion.identity) as GameObject;
    9.         Grabbable cupGrab = newCup.GetComponent<Grabbable>();
    10.  
    11.         grabber.GrabGrabbable(cupGrab);
    12.     }
    13. }
    14.  

    Add the Dispenser component to your SnapZone object and make sure to select this function in the GrabAction.

    dispense.png

    So now when you grab the trigger area, we call this function instead of a snap zone. This will Create an object and place it right in the grabber that grabbed it. Hope that helps - let me know if that doesn't make sense!
     
  47. Muskie

    Muskie

    Joined:
    Jan 21, 2017
    Posts:
    27
    Huzzah! It works perfectly, thanks! (maybe you can backport it to the main codebase? it seems like it'd be a semi-common use case.)
     
    Last edited: May 11, 2020
    BeardedNinjaGames likes this.
  48. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    93
    Hi, the asset looks good, is it possible to extend this system so hand can grab multiple object at same time? like grabing a fistful of bullet as an example. thanks.
     
  49. BeardedNinjaGames

    BeardedNinjaGames

    Joined:
    Jan 26, 2020
    Posts:
    125
    Yes, I agree this could be a useful feature as well. I went ahead and added a new boolean property called "Duplicate Item On Grab" to the Snap Zone :

    snap.png

    I can see this being useful for debug purposes. Just be careful using it, as there is no limit to how many you items can spawn :p

    grab.gif
     
  50. Muskie

    Muskie

    Joined:
    Jan 21, 2017
    Posts:
    27
    Guns.

    Lots of guns.
     
    jashan and atomicjoe like this.
unityunity