Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by abejfehr · Aug 03, 2019 at 12:26 AM · 2dcollider2dtilemap2d-physics

Ignore collisions with water if ground above water

I'd like to make a sort of a "bridge" where the player can walk over water, and I'm finding this to be extremely difficult.

player bridge tilemap unity

In the above image, the water is on the physics layer "water", the grass is on the physics layer "ground" and that board is on the physics layer "ground" as well.

Since there is no water under the ground, the player can walk, and they crash when they hit the water, so that part is good.

Now the issue is that the ground layer overlaps with the water, and when the player attempts to walk on that board they "collide" with the water.

How can I prevent collisions with water if the water's collider is "masked" by something on the ground layer?

This is what my layer collision matrix looks like:

layer collision matrix unity

scenario.png (64.9 kB)
layers.png (36.1 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image The_Groovesmith · Sep 23, 2019 at 10:29 AM 0
Share

i have the same problem did you ever finde a solution

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by $$anonymous$$ · Feb 28, 2021 at 07:36 AM

I ran into the exact same issue. What I ended up doing for my project is: Make all my tiles Scriptable Tiles, and ovrride GetTileData() like this in the class (This function is used to copy data from your Tile asset to the Tilemap that contains it):

 public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData)
 {
   tileData.sprite = this.sprite;
   tileData.color = Color.white;
 
   // Try to override colliderType of tileData of the current position
   if (this.colliderType != ColliderType.None)
   {
     var grid = tilemap.GetComponent<Transform>();
 
     // Find tilemaps that are on top of the "tilemap" (argument)
     // In my setup I always have 2 tilemaps attached to the Grid.
     // Last child always being the foreground.
     // If I had a more complicated scenario I'd loop through all children and
     // find those tilemaps that are on higher sorting layers.
     var topTilemapObj = grid?.parent?.GetChild(grid.parent.childCount - 1);
     var topTilemap = topTilemapObj?.GetComponent<Tilemap>();
 
     // If I found a tilemap, check the tile on the exact same position
     // If that tile has a "None" colliderType, I set the current tileData's
     // colliderType to "None" as well.
     if (topTilemap != null && topTilemap != tilemap.GetComponent<Tilemap>())
     {
       var tileOnTop = topTilemap.GetTile<Tile>(position);
       if (tileOnTop?.colliderType == ColliderType.None)
       {
         tileData.colliderType = ColliderType.None;
 
         return;
       }
     }
   }
 
   tileData.colliderType = this.colliderType;
 }

Output: alt text

,


bridge.png (20.5 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

285 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Tilemap Collider problems 0 Answers

Rotate tilemap collider -1 Answers

Player slips through the tilemap collider 2D. 0 Answers

OnCollisionEnter2D not calling, but objects are colliding. 1 Answer

Tilemap Colliders not working with custom tile 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges