Custom Unity layer for map

235
3
05-09-2024 12:25 AM
AR01
by
New Contributor

Hello,

I'm currently working on a project in Unity where I need to assign map tiles to a specific layer.

This would allow me to perform raycasts exclusively on the map tiles. Could you advise on the best approach to achieve this?

0 Kudos
3 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

Can you provide a bit more information about what you're trying to achieve? 

Rseason to raycast on the map might be to get an elevation value or retrieve attribute/metadata information about a specific spatial feature (e.g. building). Based on a raycast, we effectively perform an "identify" operation. For example, here's a sample showing how to identify specific features from a 3D Object Scene Layer and retrieve an attribute value: Visualize 3DObject ID's | ArcGIS Maps SDK for Unity | ArcGIS Developers. We typically think of "map tiles" as one of the tiled layer types, either vector tile layer or image tile layer which don't generally support identify operations.

 

For more info also see Mesh collider | ArcGIS Maps SDK for Unity | ArcGIS Developers 

 

Thanks  

0 Kudos
AR01
by
New Contributor

Hello,

Thank you for your reply.

I am currently raycasting on the map using Physics.Raycast and wish to ensure that the raycast specifically targets the map only, avoiding any unintended interaction with other colliders present in the scene. Typically, I would assign a layer mask to manage this; however, the map is on the default layer, which complicates the use of a layer mask for this purpose.

Could you advise on how to effectively set a unique layer for the map tiles or a way to ensure that the ray will not interact with other objects?

0 Kudos
m_d
by
New Contributor II

@AR01  You could try something similar to what's proposed in this post:

https://community.esri.com/t5/arcgis-maps-sdk-for-unity-questions/teleport-area-in-unity-for-the-que...

 

The idea is that you add a line to the Esri SDK to tag each tile generated from the scene with something unique like "ArcGIS". Then you write your own MonoBehaviour that on Update() assigns any game object with that tag to the layer you want.

I use this to add a teleportationArea to each generated tile, and to assign those tiles to a Teleport interaction layer to enable teleportation in a scene.

The downside is that, since you're making a change to the Esri SDK, you need to remember to reapply that change every time you update the SDK to a new version.

0 Kudos