r/Unity3D • u/LivingwithTOF • 4d 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
1
u/Artuplabs 4d 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/squidgeroo 4d 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 4d ago
how are you applying movement and gravity to the XR-Rig/Character-controller?
0
u/[deleted] 4d ago
[removed] — view removed comment