Colliding with Map Geometry

Colliding with Map Geometry

Example Scene

To see an example of collisions against the map:

  1. Open the scene Wrld/Demo/Examples.unity
  2. Ensure your API key is set at least on the Collision GameObject’s Wrld Map component
  3. Click the Play button
  4. Select “Colliding with Map Geometry” from the dropdown
  5. Click on the map to fire a projectile into the scene

Collision Setup

Selecting the types of geometry to generate collision meshes for

You can enable collision independently for Terrain, Roads, and Buildings by ticking the checkboxes for them in the Wrld Map inspector, as shown above.

If you’re writing a custom behaviour instead of using the Wrld Map component, you can instead set these fields in the Wrld.ConfigParams object that gets passed into Wrld.Api.Create:

  var config = ConfigParams.MakeDefaultConfig();
  config.Collisions.TerrainCollision = true;
  config.Collisions.RoadCollision = false;
  config.Collisions.BuildingCollision = true;

Performance

When collision is enabled, the API will generate collision meshes alongside the visual meshes used to draw the map. This will use more memory and add some latency to the streaming of the scene. Because of this, we recommend disabling collision for any types of objects that don’t require it.

Coordinate System

Choosing the coordinate space in the inspector, at edit time

We recommend that you start the API with the UnityWorld coordinate system when using collisions. This orients the map so that the direction of gravity points down the negative Y axis for the area around the start location, which allows for more intuitive use of Unity’s physics system.

If you do want to use collision in ECEF, you will need to make sure that Unity’s gravity vector is kept up to date, to point towards the center of the earth.

v0.8.203