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

Resolved XR Rig with Character Controller floating above the ground.

Discussion in 'XR Interaction Toolkit and Input' started by bigborax676, Mar 8, 2021.

  1. bigborax676

    bigborax676

    Joined:
    Mar 8, 2021
    Posts:
    2
    I'm new to the XR Interaction Toolkit, and I started using continuous movement, so I added a character controller so you can crawl, but It just floats at 0.5 Y. Does anyone know why this is happening? upload_2021-3-8_16-13-16.png upload_2021-3-8_16-13-44.png
     
  2. bigborax676

    bigborax676

    Joined:
    Mar 8, 2021
    Posts:
    2
    Update: I disabled everything else in the scene other than the floor, and it was still floating
     
  3. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    226
    The Character Controller component has a capsule collider to represent the character which is centered on the XR Rig. The XR Rig transform position is located at the ground, so what is likely happening is the capsule collider is going through the ground by a distance of half its height if the Center value is (0, 0, 0), which then moves the XR Rig up to make it stop overlapping with your floor geometry.

    There is a Character Controller Driver component in XR Interaction Toolkit that you can use to automatically set the center and height of the Character Controller based on the camera position so that the capsule collider will span between the XR Rig ground and the camera instead of poking through the floor. You may also need to adjust the Skin Width on the Character Controller.
     
  4. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    I'm encountering the same issue - but I can't follow your advice.
    Upon entering Play mode, the Character Controller's Center, Radius, and Height are automatically changed. (Same with the XR Origin and Camera Offset positions)
    My settings:
    upload_2022-7-13_14-15-27.png

    After pressing play:
    upload_2022-7-13_14-15-47.png


    As you can see in this demonstration, as soon as I begin continuous movement the whole rig moves up 0.5 units.


    Using:
    Unity 2020.3.30f1
    XR Interaction Toolkit 2.0.2
    OpenXR Plugin 1.3.1
    Oculus Quest 1 device.


    What should I do?
     
  5. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    226
    It looks like your Character Controller Driver component is referencing the Teleportation Provider instead of the Continuous Move Provider, so it isn't responding correctly to the move events from the latter. You'll need to change it so it references the right component.

    If you drag your Locomotion System GameObject to the Locomotion Provider field of the Character Controller Driver, Unity will pick the first (top) component that matches of which I'm guessing you have multiple, so you will need to reorder that Continuous Move Provider component to move it above the Locomotion Provider component so it will pick the right one when you drag-and-drop the GameObject. Alternatively, you can open a second Inspector window, lock the selection on one with the padlock button, and drag the Continuous Move Provider component from one Inspector window to the other.

    The
    CharacterControllerDriver.Awake
    method only tries to find the
    ContinuousMoveProviderBase
    on the same GameObject when the field isn't set. I'll add a task to our backlog so we can change it to find it anywhere in the scene instead to help with setup in a future version.
     
  6. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    Thank you! That cleared it up.

    For future readers of the thread:
    I put the Teleport Provider, Continuous Move Provider, even the two turn providers on their own child objects. I'll set up a toggle for the player to select which movement/turn style they prefer by activating/deactivating the appropriate child object.

    Note: I put the Locomotion System on the XR Origin game object, and it works fine there.


    upload_2022-7-14_14-44-38.png