Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Character Controller on Oculus Prefab flies straight up if holding item just right. #noobproblems

Discussion in 'AR/VR (XR) Discussion' started by Tset_Tsyung, Sep 21, 2018.

  1. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    Hey all,



    Long story short, borrowing Oculus Rift+Touch off of friend whilst he's away, dabbling with VR. Been working with Unity for a couple of years, but only as a hobby.

    The problem I have is that when you hold an object just directly below where the headset is in world space (or if it's big enough) then the character controller will fly straight up forever until you move the object from under the headset.

    In my Scene:
    VRissue1.PNG

    In Oculus' own "Custom Hands" scene (that little grey square is the demo scene's floor):
    VRIssue2.PNG

    Pretty sure this is something to do with the character controller, but I have hit a mental block and can't figure it out. I was thinking of simply adding anything that you grab to an ignore layer, but can't seem to find anything on the layers and methods used by the character controller for checking for ground and other obstacles "under foot".

    Where should I be looking?

    Obviously this is still a very much "Niche and professional" field, however that being said I'm having trouble finding many guides, tutorials or in depth documentation to help learn about VR development with Unity. Any pointers on this would be greatly appreciated too.

    As always, many thanks for all and any replies.

    Mike
     
    Reeconator likes this.
  2. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    Hey all,

    I'm only replying as the solution came to me once the fatigue wore off. Posting here for anyone finding this post with Google.

    Yes, a solution does exist where you can tell the physics system to NOT count collisions between the player and grabbable objects.
    You go to Edit->Project Settings->Physics. From there you can adjust which layers register with which other layers. I knew it was there, just couldn't think of it at the time .

    [See new post below as this has been updated]
    There is an issue that if the touch collider are on the same layer as the player AND that layer is set to not register with the grabbable layer then you never will be able to grab objects. But I'm pretty sure you can just set the touch controller collider to another layer again which DOES register contacts with grabbable objects. Need to test this and will edit this post accordingly.
    [See new post below as this has been updated]


    Mike
     
    Last edited: Sep 24, 2018
    Reeconator likes this.
  3. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    UPDATE: You CAN have the character's body collider set to a "Player" layer and have the controllers 'hands' set to a "PlayerTouchController" layer. This allows your to have the body ignore items you're holding whilst still being able to actually hold items...

    Proces:
    As stated in the previous post go to Edit->Project Settings->Physics
    Physics Workaround.PNG

    Then make sure that whatever layer is assigned to 'grabbable' objects does NOT have a tickbox in it where it's interactions crossover with the player collider.
    In the screenshot below I'm using the Oculus VR core integration package, where the items in the grabbable scenes are set as 'Toys'...

    Physics Workaround2.PNG

    ... of course, this is fine, but if you want grabbable items to hit (and/or bounce off of) the player then you will need to keep the 'Toys' and 'Player' interactions on, and simply assign any object that's in your hand to a new layer that doesnt have the interactions, and then reset the layer of said object once it's no longer being held.

    Anyway, as I said I'm posting this for anyone struggling with the same issue. I'm just totally embarassed that I didn't see it earlier...

    Laters,


    Mike
     
    Reeconator likes this.