Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
avatar image
1
Question by GameRKade · Nov 28, 2018 at 02:57 PM · collision2dcollider 2dprecision

Collider that can perfectly fit the shape of a sprite?

I'm trying to create the collision for one of my maps. However, I've looked online for the last hour and found nothing to answer my problem. I'm creating a tile-based game, and I want perfect collision on this sprite for one of my maps. However, I don't want to create 26 different children with box colliders to make it up. When the maps get bigger and more complicated, this will take up too much time. alt text

I want collision to occur on the red without creating a ton of colliders, but none of the colliders seem to have the kind of collision I'm looking for. I've tried the polygon collider, but due to the split-up nature of the sprite it's impossible to work with. Is there something that will allow me to easily create a collider that fits the shape perfectly?

collider.png (39.8 kB)
Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Mr_Teels · Nov 28, 2018 at 08:53 PM

Make the Red Line a Single Image. Without Floors, Walls, Etc. That is your "Collider Map". Sort it with the Sprite Layers "under" the Level and add a "Mesh Collider. Everything in the Image that has Color Information (not Alpha Channel) will be as Collider. Supported files are .png and .tiff

Comment
Add comment · Show 2 · 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
avatar image GameRKade · Nov 28, 2018 at 09:32 PM 0
Share

I have the red area as its own image. However, the mesh collider seems to only work with 3D shapes. When I try to add it, it says there's a conflict with the sprite renderer, and if I remove that to add it, the mesh collider requires a mesh filter, which only uses 3D shapes.

avatar image bluethunder3991 GameRKade · Dec 14, 2019 at 02:48 AM 0
Share

You can use a 'polygon collider 2d' for 2d objects.

avatar image
0

Answer by AdamBebkoSL · May 26 at 08:28 PM

You can make a tile that represents a wall, and this tile can be given a box collider for all instances of the tile. Then you don't have to worry about doing anything manually. If you put the tile in, the collider will just work

https://docs.unity3d.com/Manual/class-TilemapCollider2D.html

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

98 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

Related Questions

Detect collisons only on the border of a collider,How to detect collisions only on the border of a collider but not inside? 1 Answer

Problem with collider2D crosses other collider2d 1 Answer

float precision, again 0 Answers

How to prevent Navmesh Agent from overshooting destination with high Time.TimeScale? 1 Answer

Unexpected token: collider on simple ladder script 2 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