mapbox-unity-sdk icon indicating copy to clipboard operation
mapbox-unity-sdk copied to clipboard

How to check for overlapping layers ?

Open Markovicho opened this issue 4 years ago • 5 comments

  • Mapbox SDK version: 2.1.1

image

I want to spawn randomly some trees inside a specific feature (in this case landuse / park). I am using the mechanism of the GameObjectModifiers->SpawnInsideModifier. So far so good as you can see in the image below.

But i need to avoid spawning trees in the water. As those layers seems to be separated i'm in trouble creating a featuremodifier which handles this case.

how could i achieve this ?

best regards and thanks in advance

Markovicho avatar Aug 04 '20 15:08 Markovicho

@Markovicho I'm afraid there's no easy way to do this. You would have to do polygon intersection and cut them out of each other. Admittedly in current vector layer structure, it's not easy either. Maybe you can create two empty visualizers, one for forests, one for water. only add a mesh modifier to both, which passes incoming data to a single scriptable object so it'll have both forest and water polygons. Then wait for tile finished event on AbstractMap and when it fires, do all the polygon calculations and spawn stuff in that script now that you have all you need in one place. Little ugly and definitely not too easy but that should work I believe.

brnkhy avatar Aug 12 '20 00:08 brnkhy

okay thx! I will check that approach and share the results.

Another idea (only for this very specific case) could be some kind of tile-texture-colorpicking. If you know the exact rgb value of water based on the mapstyle the trees could avoid spawning above that value.

Markovicho avatar Aug 12 '20 06:08 Markovicho

@Markovicho Did you ever manage to find a way to do this? I've been searching for days on how to do it myself and haven't gotten anywhere. Seems like a pretty basic feature to add.

AvatarMars avatar Nov 10 '21 01:11 AvatarMars

Hey @Markovicho @brnkhy I know this is an old thread but did you ever get this working correctly? we have a series of map features school/church etc where we spawn prefabs, we need to not spawn these within a body of water. We have a mechanism in place to destroy any objects that intersects with each other IE we dont want buildings overlapping each other. Is there a APi feature we could use to detect the water and spawn an object within it to make use of this? is there a cleaner method ? Untitled

lukeholmes1986 avatar Aug 03 '22 15:08 lukeholmes1986

I'm sorry, I never did figure it out. Mapbox SDK for unity seems to be outdated and unreliable in general.

On Wed, Aug 3, 2022, 5:44 PM lukeholmes1986 @.***> wrote:

Hey @Markovicho https://github.com/Markovicho @brnkhy https://github.com/brnkhy I know this is an old thread but did you ever get this working correctly? we have a series of map features school/church etc where we spawn prefabs, we need to not spawn these within a body of water. We have a mechanism in place to destroy any objects that intersects with each other IE we dont want buildings overlapping each other. Is there a APi feature we could use to detect the water and spawn an object within it to make use of this? is there a cleaner method ? [image: Untitled] https://user-images.githubusercontent.com/61254196/182650855-42331062-f6fc-4e82-aad0-1a9e85a11b2c.png

— Reply to this email directly, view it on GitHub https://github.com/mapbox/mapbox-unity-sdk/issues/1657#issuecomment-1204129629, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALGV7PI4F6ENOGLHR6JPJOTVXKHVPANCNFSM4PUP6XSQ . You are receiving this because you commented.Message ID: @.***>

AvatarMars avatar Aug 03 '22 19:08 AvatarMars