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 /
avatar image
1
Question by SpoonyBard · Apr 14, 2010 at 07:26 PM · collidermesh

OnMouseDown() with a Mesh Collider?

Hi,

I'm working on a project that has house models, which are comprised of multiple meshes, each with their own mesh colliders and mesh renderers.

I have a script (that is confirmed working on anything with a Box Collider) that I want to apply to just a single mesh (outside lamps) of the house.

The script has an OnMouseDown() function, which is crucial. It won't work when applied to the mesh objects, but will work if I custom-fit a Box Collider over the object. This is a pain though, and won't work if the parts of the model aren't contiguous.

Is there a simple solution to this? Am I being stupid? Any help would be appreciated!

Thanks, SpoonyBard

EDIT: Turns out it might not be related to Mesh Colliders, as a Cube with a Mesh Collider works fine. Is there a setting to do with the model itself that I might be forgetting? The house and all of its parts seem to collide fine!

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 alexnode · Apr 14, 2010 at 08:34 PM 0
Share

Could you describe a bit more what do you want to do with the mouse down, to see if we can help? You could add a mesh collider to any object by going to the menu - add component - mesh collider. If you want a trigger tick the isTrigger check box.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Molix · Apr 15, 2010 at 03:23 AM

When this sort of thing happens with us, it is typically because the collision mesh doesn't match up to the visual mesh. The most common causes: a rotation of one that is not applied to the other, or a scaling difference. Selecting the object in the hierarchy should highlight the collision in light green for a visual check.

Sorry if this is obvious, but it happens to us enough that I figured it was worth mentioning.

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
avatar image
1

Answer by Zeroth · May 06, 2010 at 08:23 PM

The problem is that if you have a complex conglomeration of several meshes, when you click on one, it does do an OnMouseDown event... but it does not send that event upwards. So if you have a house composed of several meshes, then clicking on it is working as intended... but the top level parent is not receiving the click events.

A couple ways to solve this:

Make a simple script with a variable for the parent, then place the script on each child mesh. This script will simply have an OnMouseDown event that will find the key script on the parent, and call the relevant functions there.

Put the key script on every child mesh(not recommended for bigger meshes).

Comment
Add comment · Show 1 · 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 Matt-Face · Jun 03, 2013 at 01:50 PM 0
Share

@Zeroth

Thanks this comment helped me a lot!

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

1 Person is following this question.

avatar image

Related Questions

Is it possible to make thousands of colliders at once? 1 Answer

Ignore/Destroy then re-enable Mesh Colliders 3 Answers

Check for collisions with script outside of object with collider 0 Answers

Have a collider spit out any intersecting colliders to the closest next to them where there is no collision 0 Answers

How to make audio play when passes a collider 1 Answer


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