Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question How do layers work?

Discussion in 'General Discussion' started by Cosmology27, Feb 20, 2023.

  1. Cosmology27

    Cosmology27

    Joined:
    Jul 11, 2019
    Posts:
    61
    I've looked into this different times, but it seems like they constantly don't work, so I'm guessing I just don't fully understand layers. I have a bow, every single piece of the bow has the "Weapon" layer. In project settings, under physics, I have turned off literally every single box for weapon, so it "should" interact with nothing. However, it bashes into everything. I have a wall with a default layer, and the bow is colliding with it. I also have my player with a player layer, and the bow interacts with it, which is annoying because it affects running. I'm guessing I'm missing something, but I thought the grid of boxes in project settings determined whether different layers would interact physically with each other. What am I misunderstanding? And how do I actually make different physical objects not interact with each other? Thanks.
     
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,759
    Show us a screenshot of your layer configuration.
     
    CodeSmile likes this.
  3. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,878
    It sounds a lot like you have added rigidbodies and colliders to things you shouldnt have. Please post screenshots of your hierarchy and inspector on the object in question, as well as layer configuration in physics settings.
     
  4. Cosmology27

    Cosmology27

    Joined:
    Jul 11, 2019
    Posts:
    61
    https://imgur.com/a/wmIWafB
     
  5. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    571
    I think we'd need to see a screenshot of your objects in the editor. Is a rigidbody or collider a parent or child of the bow?
     
  6. Cosmology27

    Cosmology27

    Joined:
    Jul 11, 2019
    Posts:
    61
    So it's a little hard to get all the necessary data in, but here's the bow itself which has the rigidbody and the collider.
    There is a small sphere collider with a rigidbody on the string, but only for grabbing purposes to draw it back, also that's not the part that's giving me trouble (the handle is the main big collider you see on the bow object itself, which collides with everything, even though it shouldn't).
    There are no other colliders or rigidbodies within the hierarchy of the bow. And as you can see, the only parent for the bow is an empty, being used for organizational purposes.
    Also every single object in the bow hierarchy is on layer "Weapon".
    https://imgur.com/a/D81chsG
     
  7. Cosmology27

    Cosmology27

    Joined:
    Jul 11, 2019
    Posts:
    61
    I got the pic in the previous message. Any ideas why the layers are still interacting with each other? It's a pretty simple rigidbody and collider setup, with the layer "Weapon" not check with anything, and yet it's interacting with everything. Any ideas why? It's kind of ruining a lot of my game. Even my arrows are interacting with stuff they shouldn't, which hinders firing them at times.
     
  8. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    571
    Well it doesn't look that simple! I can't see what layer your bow is on and since you have those HVR scripts for interaction they would be using physics as well. Does the layer change when you hit Play mode?

    You are correct that if your layer is disabled it should not be interacting with anything. So, some part of that hierarchy or script is not on that layer.
     
  9. Devastadus

    Devastadus

    Joined:
    Jan 27, 2015
    Posts:
    73
    If you setup a simple project it would work. I use layers in mine and they work as expected. I suggest it could be some child gameobject has a collider and it is not on the weapon layer. Or something in your scripts is changing the layer.
     
  10. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,878
    I mean you have a bunch of HVR scripts interacting with who knows what, but seeing as they are clearly intertacting with physics, I recommend actually getting in touch with author of those scripts first. When saying "layers interact with each other" you have to eliminate 3rd party code first to be sure its a unity issue. This is a 3rd party issue more likely than setup issue.