- Home /
Google Cardboard: RigidbodyFirstPersonController script attached to its camera is falling through the floor
I have followed the Checklist: Object or Character is falling through the floor. This problem is different as it only happens with Google Cardboard (5.2).
I have attached RigidbodyFirstPersonController.cs to the Main Camera [1] and played with its options. I also have followed this tutorial which I think uses the old first person controllers.
If I use the keyboard or the mouse to move through the enviroment, it works well. Unfortunatelly, if I use the smartphone [2] it will fall through the floor if I focus to the floor (specially if I'm climbing a mountain). [3]
Other possible workarounds I have done unsucessfully:
Increase the radius of the capsule collider or the height. Increasing the height improved it. It was harder to fall through the fall.
Change the collider to sphere.
Possible workarounds I have thought, but not try (or I have tried, but I can try harder):
Use a character with the third person controller. The camera would follow that character.
Doing more modifications of the RigidbodyFirstPersonController script (I did this one)
Change some script/s of the Google Cardboard asset, study it deepler to understand how it uses the accelerometer.
Untick the track rotation option. Use or code another controller which uses the accelerometer.
I think the above solutions would consume a lot of time. So, do you have some other idea? Did you solve this problem before?
[1] If we attach it to Head, it does not work unless we untick Track Rotation. We need to use the accelerometer to move the camera, so we need to tick Track Rotation (or use another controller to deal with the accelerometer). By the way, the raycast does not work well if I attach it to the Head either: the raycast intersect other objects, but the exit event is called before exiting (even if I use the ignore raycast tag).
[2] Or I use the mouse keeping the Alt button pushed. It is how the movement with the accelerometer is simulated within the Unity Editor.
[3] To make the camera always walking forward, I have modify the RigidbodyFirstPersonController.cs adding a input.y = 1f;
as I explain here.
Answer by chelder · Nov 06, 2015 at 02:17 PM
So far, the best workaround I have done is the following:
Drop to the Hierarchy the prefab coming with the Standard Assets: Characters > ThirdPersonCharacter> Prefabs> ThirdPersonController
Add the CardboardHead.cs script to the ThirdPersonController gameobject. Enable track rotation and disable track position.
Disable the CardboardHead.cs script from the Head gameobject (I guess removing the Head gameobject would be OK too).
Attach the Main Camera as a child of the ThirdPersonController gameobject (that camera should have the left and right camera).
In order to the player is walking forward all the time, I have also done the following modification to ThirdPersonUserControl.cs:
// Fixed update is called in sync with physics
private void FixedUpdate()
{
// read inputs
float h = CrossPlatformInputManager.GetAxis("Horizontal");
float v = 1f; // CrossPlatformInputManager.GetAxis("Vertical");
If we attach the controllers to the camera, it does not work because if we look down, the camera could be above the floor, so the camera would fall through the floor.
However, if we do what it is described in this answer and attach the controllers to another game object, we remove that problem.
Notice we can also use a cube or any other game object with a rigidbody and make it invisible. Doing that, it would be like a first person game.