• 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 Thierry_J · Apr 04, 2016 at 07:22 AM · onmousedownmesh collider

OnMouse down does not work with a mesh collider

I am working on a project in which I want to select and drag complex objects with the mouse. I have previously done this in another project using regular colliders and the OnMouseDown function, but this is not working with mesh colliders. For now, I have a simple script that is supposed to change a public bool when the object is clicked ( I am using OnMouseDown). I am not detecting any click when I click on the complex objects with mesh colliders. I have tried using the same script on the objects with a sphere collider and also on a cube with a mesh collider. Both of these worked, so I do not think there is a problem with my script. These objects were downloaded online and I am not sure how they were made. I imported them into Blender before importing them to unity after. Can anyone think of why my script is not working or do you have any ideas for how I could select and drag the objects in a different way? Thank You

Comment
Add comment · Show 4
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 Fredex8 · Apr 05, 2016 at 12:16 AM 0
Share

Is convex ticked on the mesh collider?

avatar image Thierry_J Fredex8 · Apr 05, 2016 at 02:06 AM 0
Share

I tried it both with and without convex checked and none worked. When I check the convex button I get an error because my convex hull has more than 255 polygons.

avatar image Fredex8 Thierry_J · Apr 05, 2016 at 10:00 AM 0
Share

Ah well that's going to be an issue anyway then. $$anonymous$$esh collider shouldn't be used with high poly objects or its going to be really inefficient. You would also need to export a vastly simplified version of the mesh and set that as the collider for the complex mesh in the mesh collider settings.

When you say they are complex objects what do you mean? One high poly mesh like a character model or something made of lots of separate objects?

Show more comments

1 Reply

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

Answer by Fredex8 · Apr 05, 2016 at 01:10 PM

It depends on what you are going to do with the brain model in Unity but realistically I'd say it's a bit too complex for most game uses anyway. Or at least unnecessarily complex. Each hemisphere of the brain is over 38,222 tris. All parts combined are 94,716. That's significantly higher than characters, objects, buildings etc use in modern games.

If the brain is the sole focus of the game (like an anatomical lesson on the brain) then that might be ok, although as the whole model only breaks into 6 parts it probably isn't detailed enough for that. If you intend to have other things in the game or multiple instances of this brain then it is really far too high. Either way the tessellation could definitely be heavily optimised and a lot of the ridges and furrows created with normal maps instead.

However I also see a good deal of pinches in the mesh, weird normals, some gaps in the mesh and edges that intersect faces so in all honesty optimising it would probably take longer than it would be worth compared to finding an alternative model which is lower poly to start with. If you do use this model be aware that these errors may be visible from some angles and make it look a little ugly.

If you just need to detect clicks on the brain parts without them colliding with anything else then they can use a non-convex MeshCollider however they cannot have a rigidbody on them then. Still 38,222 tris is far too high for a collision mesh though and it would need to be cut down significantly for performance reasons.

If you need the parts to actually collide they would have to be convex and that means the collision mesh would need to be below 255 tris (not sure why the error message says polygons when the documentation says triangles).

To create a collision mesh for this you basically just want to model a mesh that describes the rough shape of the brain parts with as few triangles as possible. Even running this model through the automatic optimiser in Max at 1% vertex count it's still too high for a convex mesh though. All of those errors I mentioned also cause problems with this so however you do it a degree of manual work is going to be required.

You can probably find some good tutorials for creating collisions meshes in Blender online.

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 Thierry_J · Apr 06, 2016 at 04:01 AM 0
Share

Basically, I just want to select these parts to control them with a 3D mouse for demonstration purposes. I do not need a very precise model, I simply chose that one because it was free. Is the best method therefore to make a custom collision mesh in blender? How does that work ? Do I need to make a similar looking (simpler) object and attach that where it ask for the mesh in the mesh collider? Thanks

avatar image Fredex8 Thierry_J · Apr 06, 2016 at 11:06 AM 0
Share

Yeah that's the idea. As you are using it just as a trigger for the mouse it can be very basic, essentially just a simple shape that surrounds the complex mesh.

avatar image Thierry_J Fredex8 · Apr 07, 2016 at 02:15 AM 0
Share

This worked! Thanks for your help! I made simple replicas of the object in blender and added them as mesh colliders.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

OnDestroy collision detect 4 Answers

Stop a Lerp from looping 3 Answers

OnMouseUp error 0 Answers

iOS multiTouch / release - Strange problem 0 Answers

OnMouseDown If-statement Question 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