the camera of the oculus rift player prefab moves out of the rigidbody??

i have the oculus rift player prefab in my scene. when i move around in real life in front of the sensor, the camera moves but the player holds the same position. so when i walk into a wall in game, i can move through the wall. how can i keep the camera in the player body?

this is when i start up. and stand still:


this is when i walk (in real life in front of the sensor):

i want the green collider and the camera to move together. but how??? is this possible

VR cameras have a local offset applied by the VR system. This means that as you move around in room scale (or even around in front of a single sensor) your camera will be allowed to move outside of the character controller.

Additionally, I’d recommend not bothering with a CharacterController at all if you’re doing a room scale experience. CharacterController is intended for when you want to forcibly move a character in a scene, but with room scale you want the player’s position in their play space to dictate their position (relative some point in the scene to account for moving through larger scenes).

The best strategies I’ve heard of to deal with walking through walls tend to be things like applying some kind of effect to the camera so the user still perceives motion when clipping through walls but isn’t able to see level geometry outside that they shouldn’t. I don’t have any examples off hand, but it’s definitely one of those tricky problems with room scale VR.

thanks for your reply. im using roomscale and a controller to move around. but i think it wil be a seated expirience from now on. the only head tracking used will be when your move your head left, right, up and down.

Are you aware of any ‘prefab’ characterControllers that DO work with the oculus for locomotion around a room scale environment?

You might have added Rigidbody component to the camera that is why its happening remove the Rigidbody component and it will work fine.

I was having this problem recently and couldn’t find any proper solution at all then generated my own solution. Here Im gonna detail it. Firstly my main problem was when player moved in real life then move over controller since its center collision is at different place it was stucking collision it shouldn’t be such that when player tries to move just near table collider stucks at table but player’s front looks like free to move.

My Solution:
Firstly I generated a script that carries collider to Center Eye Anchor’s X and Z axises. Such that whenever player moves collider comes with it. It was okay for my problem but then I figured out this leads another big bug. It blocks us to bend over tables etc. it also blocks to goes inside walls which is okay but preventing us bending over objects is not good at all. So I generated another script which closes my first script at collider enter and placed this script over objects that I wanted to bend and when I exit trigger it is opening script back such that I can bend over everything that I want and also I don’t stuck anywhere. It works well so far. If you get any bug over this let me know. Also here my scripts:

Script for collision problem

/*
This code is generated by Sasete. reach me over here, SaseteS@icloud.com
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VRCameraCharacterControllerFix : MonoBehaviour {
   
    public CharacterController character;
    public GameObject centerEyeAnchor;
    private Vector3 place;
   

    void FixedUpdate()
    {
        place = new Vector3(centerEyeAnchor.transform.localPosition.x, 0, centerEyeAnchor.transform.localPosition.z);

        character.center = place;
    }
}

Script for closing first script

/*
This code is generated by Sasete. reach me over here, SaseteS@icloud.com
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VRCameraCollisionFix : MonoBehaviour {

    public GameObject OVRCameraRig;
    private VRCameraCharacterControllerFix VRCameraCharacterControllerFix;

    private void Start()
    {
        VRCameraCharacterControllerFix = OVRCameraRig.GetComponent<VRCameraCharacterControllerFix>();
    }

    private void OnTriggerEnter(Collider other)
    {
        if(TriggerVRObject(other))
            VRCameraCharacterControllerFix.enabled = false;

    }

    private void OnTriggerExit(Collider other)
    {
        if (TriggerVRObject(other))
            VRCameraCharacterControllerFix.enabled = true;

    }

    private bool TriggerVRObject(Collider other)
    {
        if (other.gameObject == OVRCameraRig)
            return true;
        else
            return false;

    }

}
1 Like

Hey did this work?
Cause when I tried this the collider was not moving perfectly with the camera.It was not like not moving at all.
It was moving perfectly when I was looking forward but when I looked back the collider was far away from the camera so ,Player was unable to move.

Hi There,
I solved this problem by using buit in prefeb which is in the scene called “Locomotion” and its path is “Assets\Oculus\SampleFramework\Usage” and prefeb name is “PlayerController”.

It works like charm.

1 Like

This is how you use scripts, only first code is for OVRCameraRig it simply teleports OVR camera rig to the Center Eye Anchor’s position continously.
4439959--406330--upload_2019-4-17_16-46-50.png

And there is Wooden Platform that we have to bend over. To be able to do that, you have to enter this script over that, this script is just disable first script on trigger enter and when trigger exits re enable it

4439959--406336--upload_2019-4-17_16-49-42.png

1 Like

Yes, the CharacterCameraConstraint.cs script from the example scene Locomotion (Oculus Integration) solves the problem as @WR-reddevil suggested. I recommend adding that anyways, it also gives you the correct height for the player.

2 Likes

Yes, just add CharacterCameraConstraint.cs and it will work

Hi, correct :-). Make a Capsule, put the OVRCameraRig into as a Child and add the CharacterCameraConstraint Script to the Capsule. That´s it. GREAT :slight_smile:

I tried this as of September 2020, and it no longer seems to work. In fact, building the original sample doesn’t work either… no collision checking when moving in room scale seems to take place at all.

1 Like

Hi All, I am also getting the same problem. I have added the CharacterCameraConstraint script to my PlayerController but still I am getting same problem.

Can anyone please help me to resolve this problem?

Thanks in advance.

Dude, I can’t thank you enough. I’ve been struggling with it for 2 years in my project. THANKS!!! I feel like celebrating now! haha I would hug you if I was close!