Jump to content

Collision mask on biome not being respected


Bil Simser
Go to solution Solved by designleviathan,

Recommended Posts

Either that or I'm not understanding a biome mask. I have a scene with a factory on a terrain. After spawning the biome the trees, rocks, etc. were being spawned in the area. So I added a collision mask to the biome, set the mask type to Layer Game Object, created a layer for the buildings, added them all.

I visualized the biome before spawning and it all showed how it would avoid the buildings. Great.

726312502_2022-02-06(2).thumb.png.0f086323478534c349130124f359d734.png

However after spawning the biome I still ended up with trees taking over the area it should have avoided.

2022-02-06.thumb.jpg.bf3fa49dd0a7f843e6753833dde351bf.jpg

I'll try adding a separate collision mask to each of the spawners but I thought the biome mask would cover it for all spawners? Or am I misunderstanding something about a biome collision mask?

Thanks

Link to comment
Share on other sites

  • 2 months later...

I'm having this same problem too. Certain objects are respected on layers but not others. I even tried adding a big box collider to see if a simple blocker would help but no dice.

Link to comment
Share on other sites

@designleviathan Could you please provide a screenshot of objects not being recognized? In general the collision mask works by doing an overhead render - this means the visual shape is the relevant info it captures, not the collider. We did have issues in the past where either special shaders or render pipeline settings could cause an issue with the collision masks, but normally if it is an object that is visible on a certain layer, it should also work in the collision mask.
Another thing you could try is to open the file BakedMaskCache.cs and comment out line 327 with two leading slashes, so that it reads:

//    OrthographicBake.RemoveOrthoCam();

then save the file and visualize the spawn rule containing the collision mask. You should then see an additional camera appear in the scene hierarchy. If you select that camera, you can "see what the collision mask sees" in the Game view.

image.png

By looking at the camera and comparing against the scene view you might be able to figure out why those objects "cannot be seen" by the collision mask. 

Link to comment
Share on other sites

I will try that later today thank you. I found the tag mask to work as expected so just used that quickly to muddle through but I'll try the collision masks again because i will definitely need them later.

 

Using URP on 'default unity' settings

Link to comment
Share on other sites

  • 2 weeks later...

@Peter I did as you asked and TBH in the ortho cam it doesn't see anything.

I didn't screen cap this because it's just 100% black. But I can go back and do this if you'd like.

I did experiment heavily (to eliminate obvious user error) and captured what I hope are clear screenshots of behaviour i described of certain masks not working.

Screenshot Context

  1. Collision Mask -> Tag Radius
    1. Notes: Works as expected
  2. Collision Mask -> Layer Game Object
    1. Object mask is 'offset' from objects 'real' position.
      1. I would describe it's offset transform as rotated and flipped from actual object position.
    2. Seems to miss some objects but they may just be offset as noted above and now being clipped by biome boundaries

 

Additional Notes

  1. I have removed all other ortho cams (had one other to generate map screenshots) from my scenes.
  2. I have switched the game objects back to Unity's standard URP lit shader to avoid any possible issues from that ( it didn't seem to affect it before for the other masks)

 

RadiusTag_Screenshot 2022-04-22 143249.png

LayerGameObjectMask_Flipped Mask_Screenshot 2022-04-22 142147.png

Link to comment
Share on other sites

Apologies I didn't include the proper screenshot with the inspector for the Layer Game Object Mask - attaching it to this comment

LayerGameObjectMaskWInspector_Flipped Mask_Screenshot 2022-04-22 142147.png

Link to comment
Share on other sites

@designleviathan Thanks for checking! The mask being flipped is interesting - we had I think 2 other users with the same issue. It seems that there is *something* in URP that somehow affects the way our hidden collision mask camera captures the image. Normally we internally need to flip the captured image, for our purposes, but for a low % of users it seems that for them the image is already flipped during the capture. Could you please try the following: Open the file OrthographicBake.cs and comment out the lines 157 to 164 so they look like this:

image.png

Then save the file, check the visualization again and Refresh the collision masks so that they are forced to refresh the collision data.
image.png

If that fixes your issue, we might turn this into an official option until we find out what the dividing factor is that causes this for some of the users.

  • Thanks 1
Link to comment
Share on other sites

@Peter appreciate the quick reply - I had a bit of a sinking feeling it's something URP-connected - I will investigate this tonight and report back later / in the morning which ever comes first.

Currently waiting for some spawn rules to finish on something unrelated so once that's done I'll dig in.

Have a great weekend!

Link to comment
Share on other sites

  • 3 weeks later...

Following.. I'm having the same problem, I guess not only for trees..

note that the rocks collider are also wrong.. some shifted, some not even there..

spacer.png

Link to comment
Share on other sites

Following.. I'm having the same problem, I guess not only for trees..

note that the rocks collider are also wrong.. some shifted, some not even there..

spacer.png

As I checked here, the root object of the small farms "Small Farm 1" (child of Gaia Game Object Spawns) is being rotated on X by -180. On the image below the houses are upside-down.

Jp7Dy4B.png

Edited by Claudio
rounded the x flip in grades, makes more sense
Link to comment
Share on other sites

  • Solution
On 5/11/2022 at 4:51 PM, Claudio said:

Hi again, sorry for the spam.. I just fixed the bug for me.. 

wy6fStA.png

I just commented this line:

Pk5HwCL.png

Just catching up now - great catch. Thank you for sharing

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Hello,

I had the same issues described by designleviathan. (I'm using Gaia Pro with Unity 2019.4.13 and URP).

Quote

Collision Mask -> Layer Game Object

 

  1. Object mask is 'offset' from objects 'real' position.
    1. I would describe it's offset transform as rotated and flipped from actual object position.

For some reason , the "UPPipeline" scripting define entry was missing ( lines 157 to 164 of OrthographicBake.cs. could'nt work without it). 

Following the blog post below, I added "UPPipeline" into Edit > Project Settings > Player > Other Settings > Scripting Define Symbols : problem solved !

Have a good evening.

  • Like 1
Link to comment
Share on other sites

@Moondrakor  Thanks for posting that additional solution - I have seen this a few times where the UPPipeline define was missing, but I do not know what causes it, this define is normally being created during the Pipeline switching process in Gaia. There must be something that removes that define afterwards again.

Link to comment
Share on other sites

  • 5 months later...
On 4/22/2022 at 10:48 PM, Peter said:

@designleviathan Thanks for checking! The mask being flipped is interesting - we had I think 2 other users with the same issue. It seems that there is *something* in URP that somehow affects the way our hidden collision mask camera captures the image. Normally we internally need to flip the captured image, for our purposes, but for a low % of users it seems that for them the image is already flipped during the capture. Could you please try the following: Open the file OrthographicBake.cs and comment out the lines 157 to 164 so they look like this:

image.png

Then save the file, check the visualization again and Refresh the collision masks so that they are forced to refresh the collision data.
image.png

If that fixes your issue, we might turn this into an official option until we find out what the dividing factor is that causes this for some of the users.

This fixed the problem for me. I am using URP and Gaia Pro 3.3.5-c5.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hey there,

iam using Gaia Pro (3.4.1-c5) with Unity 2022.3.14f1 and running into some weird behaviours of the Spawning Collision Mask.

This is a bigger World Scenario, and the Collision actually look like planed. (except for the weird stripes at the side) - CollisionMask_good

Once Iam generating this, it ends up messing around. - CollisionMask_bad

I tried the posts before, like commenting out the orthographic stuff and also the flipping, but for me its not working.

In a small World Scenario for testing, with only one Terrain, everything works. Once its multiple terrain everythings gets weird.

Any Ideas or Solutions for this?

Best whishes

 

 

CollisionMask_good.png

CollisionMask_bad.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...