Detect collisions inside OSM Buildings

I am trying to create logic to detect if a randomly placed object is inside an OSM building. Since the mesh colliders for the OSM Buildings only applies to the outside is there any way to do this? I have tried using RayCasts and Collision detection logic, but those do not work since the inside of the building has no colliders applied to them. Is there a way to add them to the OSM Building generation or another way to detect if a game object is inside an OSM Building?

Rather than ray casting from the game object outward and checking if you hit a building, reverse it. Cast a ray from a large height above the game object, down toward the game object, and see if that ray hits a building.

1 Like

That did the trick! Thanks!

I tried it but the Raycast wont detect the buildings. It detects a regular plane or box tho. I am probably missing something. Can someone help?

Hi @Eylul, welcome to the community!

The first thing to check is that createPhysicsMeshesis enabled on the Cesium OSM Buildings Cesium3DTileset. Physics meshes are required for raycasts.

If that is not the problem, it may help us diagnose the problem if we could see the code you’ve written to do the raycast.