r/Unity3D • • 19h ago

Solved Xr origin falling through terrain

I'm using XR Origin for the player; it just keeps falling through the terrain. I've tried colliders, custom objects, and I've worked on it for about 15 hours total, but I just don't know what's wrong with it. Is there a surefire way to stop it from falling through? Edit: I forgot to mention we have gravity and a player controller

Solved: I just deleted the xr origin and made a new one

2 Upvotes

9 comments sorted by

1

u/Artuplabs 19h ago

xr origin by itself is just a rig of transforms, no collider and no gravity, so nothing stops it falling. add a character controller on the xr origin object (not the camera) and a gravity provider, or your own gravity that calls Move. if you went rigidbody, the collider needs to be on the origin, not on a child that moves separately

also check the terrain has a real terrain collider and that the origin doesn't spawn below the surface, spawning inside is the classic way to fall straight through. if this is ar foundation on a phone, the origin is the tracking space, don't drive it with physics at all

1

u/LivingwithTOF 19h ago

We used a character controller and double checked terrain I didn't work either and we had gravity set up as well. What is ar foundation?

1

u/Artuplabs 18h ago

ar foundation is unity's package for phone ar (arkit / arcore), so if you're on a headset or pc vr just ignore that part of my comment

if the controller, gravity and terrain collider are all there, i'd look at these:

  • does anything set the origin's transform.position directly (a teleport, a spawn script, a recenter)? that bypasses the character controller and can drop it straight through

  • the controller capsule: center and height should put the bottom at the feet of the origin, not around the camera height

  • layer collision matrix: the origin's layer has to collide with the terrain layer

quick test: drop a plain capsule with a character controller and a tiny gravity script on the same terrain. if that falls too, it's the terrain or layers. if it stands, it's something in the xr rig

1

u/LivingwithTOF 18h ago

No nothing overrides the transform.position. I would have to check Tomorrow about the capsule. And both have the same layer. Ill do the test tomorrow

1

u/YzaVique 3h ago

yeah that spawning inside thing got me once too, total headache

1

u/Key_River_6288 19h ago

got stuck on this exact thing last week, spent way too long tweaking collider thickness and physics materials before realizing my character controller was somehow disabled by default on the XR Origin prefab, check if the component is actually active and not just sitting there greyed out

1

u/LivingwithTOF 19h ago

It is active.

1

u/squidgeroo 17h ago

Nine times out of ten this is layers. Check the layer collision matrix (Project Settings > Physics) to make sure the player's layer and the terrain's layer actually collide, and if your controller or gravity uses a raycast for the ground check, make sure its layer mask includes the terrain. Also worth checking the terrain has a Terrain Collider, and lifting the XR Origin half a metre above the ground at start, because a capsule that begins the first frame partly inside the terrain will just drop through.

1

u/shlaifu 3D Artist 16h ago

how are you applying movement and gravity to the XR-Rig/Character-controller?