• 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 Mahamed9628 · Nov 07, 2011 at 08:00 PM · rigidbodyraycastingonmousedown

Rigidbody and raycasting

I have a little shuttle with interactive cockpit. If there is no rigidbody, attached to a shuttle, all buttons working correctly. But attaching rigid to a ship let buttons ignore raycasting (I think so). Buttons are childs of shuttle. Every button has collider and script, where function OnMouseDown() sends a some signal to shuttle' script. What should I do to shutdown that problem? (It's so negative influence of rigids to all my completed work...)

Comment
Add comment · Show 3
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 Owen-Reynolds · Nov 08, 2011 at 01:57 AM 0
Share

rigidbodies don't interact with RayCasts. If you read the RC docs, they hit colliders and triggers (which are types of colliders.)

avatar image syclamoth · Nov 08, 2011 at 09:00 AM 0
Share

This is pretty much an issue with semantics- a raycast will still return information about rigidbodies they connect with, even though the rigidbody itself isn't the thing it actually collides with. Saying that rigidbodies don't interact with RayCasts is like saying that keys don't open doors (because handles do).

avatar image Owen-Reynolds · Nov 08, 2011 at 03:14 PM 0
Share

Having or not having a rigidbody has no effect on whether a rayCast works. There is no need to add an RB to enable rayCasts. When you added them, you must have changed something else (maybe you had a "wall" blocking you that fell over when you added an RB to it.)

Here's a testing set-up: http://answers.unity3d.com/questions/178483/is-it-possibel-to-allow-a-raycast-to-pass-through.html

6 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by dannyskim · Nov 07, 2011 at 10:37 PM

By simply taking a look at the Unity Script documentation, there is a layerMask argument that you may be able to make use of.

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
0

Answer by Mahamed9628 · Nov 08, 2011 at 08:25 AM

I know about layerMask. But there is no ray that I defined. It's just function OnMouseDown() on every button. Or I can define layermask for it?

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
0

Answer by Mahamed9628 · Nov 08, 2011 at 08:25 AM

I know about layerMask. But there is no ray that I defined. It's just function OnMouseDown() on every button. And it does not works if button is child of some object with rigidbody. It still on Default layer, layer not change.

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
0

Answer by Mahamed9628 · Nov 08, 2011 at 08:57 AM

rigidbodies don't interact with RayCasts

What a mess? I have tested raycasting on rigidbody, it works! It does not works on childs of rigidbody...
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
0

Answer by Mahamed9628 · Nov 08, 2011 at 09:37 AM

Ok, I get it (maybe). And how to let it working? Take a situation: We have a plane, that has rigid and collider. Also we have one button, that is child of plane. It has collider only. And how to press that button using OnMouseDown() or same func? I dont believe that its impossible.

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
  • 1
  • 2
  • ›

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Using a range of raycasts with varying angles. 3 Answers

Clicking on a child object. 1 Answer

wasd movement rigidbody no bouncing 0 Answers

Collision detection problem 0 Answers

Slow Motion Camera translate and back 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