Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by imnickb · Mar 23, 2013 at 11:21 PM · 2dcollisionspritegeometry

How do you create complex collision geometry to match 2D sprites?

I'm making a 2D game where objects spawn on the right side of the screen and slide to the left side of the screen where they collide with the player. Most of the objects are simple shapes where rectangular collision boxes work well but some are large, oddly shaped rocks and I need to have the collision boxes be a little truer to the shape of the image on the sprite. How do you create more complex collision geometry?

The only way I can think to handle this is to make a mesh in Blender or a 3D modeling program, then import the mesh and assign it as collision geometry to the sprite. Does this sound right? I'm not very experienced with this stuff and modeling is not something I have a lot of experience with.

Thank!

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 whydoidoit · Mar 23, 2013 at 11:35 PM 1
Share

Yeah that's one way for sure - things like 2D Toolkit have that built in. You could build a unity tool to describe your objects shape - but it's a decent amount of work to make it nice graphically.

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by sparkzbarca · Mar 24, 2013 at 02:15 AM

you can also just use a compound collider.

baiscally you make an empty game object and you make it a child of the rock and add a collider

make another empty game object. make it a child. make a collider

you can then have multiple shapes for one collider. A compound colilder. it's built in supported.

So you can use a large square for the center area and smaller squares and spheres around the edges that togehter conform cloesly to the shape.

Comment
Add comment · Show 3 · 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 sparkzbarca · Mar 24, 2013 at 02:16 AM 0
Share

all your doing then is saying I want 1 large square + 2 smaller squares + 2 spheres + capsule or whatever I want all these to be a collider of the rock and anytime any of these are hit just treat it as if the rock was hit.

avatar image imnickb · Mar 24, 2013 at 09:28 PM 0
Share

I thought I'd post some more information on the methods I found in case anybody's having trouble with this like I was.

  • The compound collider method sparkzbarca described. Create several colliders to replicate the shape of your sprite.

  • Use the 2D toolkit to click and drag points to create a polygon collider to match your sprite: http://www.unikronsoftware.com/2dtoolkit/doc/tutorial/creating_polygon_colliders.html

  • Create a mesh in a 3D modeling program to use as a collider for your 2D sprite. http://www.rocket5studios.com/tutorials/creating-2d-games-with-unity3d-part-5-complex-collision/

If you don't have the 2D toolkit or a program like Blender or $$anonymous$$aya, it looks like the compound collider method is the way to go. The 2D toolkit method is by far the cleanest, easiest way if you have it.

avatar image nikomikulicic · Mar 04, 2014 at 10:36 AM 0
Share

You guys seem to go with compound colliders in 2D without any trouble. Can you please try to recreate my scene and see if I'm doing anything wrong? I posted a question here: http://answers.unity3d.com/questions/652188/compound-colliders-not-working-in-2d-unity.html

Scene is as simple as it can get, but for some reason, I just can't make a compound collider work for 2D.

Thank you very much!

avatar image
0

Answer by Asvaronn · Apr 29, 2015 at 09:52 AM

By now (probably added in Unity 5?) you can create a Polygon Collider 2D in Unity which does the same as the 2D toolkit polygon collider.

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

14 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

Related Questions

Implementing 2D Sprite Collisions 1 Answer

Collision detection not working properly with 2D sprites 1 Answer

I drew a 2d Maze. How to collide with walls. 1 Answer

Strange 2D sprite behavior 0 Answers

How do I check if/where in a sprite another sprite is? 0 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