• 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
Question by superstar123 · Nov 28, 2011 at 08:37 AM · raycastlayersignoreonmouseover

function OnMouseOver() ignore selected raycast

I want when I call function OnMouseOver() or function OnMouseDown()... I want my mouse point ignore selected raycast to do something like this:

For example,I have object A, B, and D,

I attach this script to my object D

function OnMouseDown(){

   //my mouse pointer ignores object A
   //do something

}

And I also attach another script to my object D:

function OnMouseOver(){

   //my mouse pointer ignores object B
   //do other things

}

I mean from the position of the screen, you will see object A and then D in the line (so D is hidden). And if my mouse pointer is at object A (of course Object D is right after object A ), I click object A, but object D will be clicked, and this script is done.

I know that I must put my object A into the layer "ignore raycast", but there are other thing I want to do with object A; so I want to a script to ignore selected raycast, not put into that layer.

And it's similarity with my object B

Can someone answer this for me please? Sorry for my bad english :(

Thanks a lot, regards

Comment

People who like this

0 Show 5
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 superstar123 · Nov 28, 2011 at 06:29 PM 0
Share

can someone help me plz :(

avatar image WillTAtl · Nov 28, 2011 at 06:33 PM 0
Share

It is not really clear from your question what you're trying to do, or how we can help with it. You'll need to explain the pseudocode comments more, what do you mean by "my mouse point ignores object A/B?"

avatar image cj_coimbra · Nov 28, 2011 at 06:44 PM 0
Share

You are trying to make your mouse pointer ignore object A as soon as object D is clicked? Or are you trying to ignore object A because both A and D have this same script?

avatar image superstar123 · Nov 29, 2011 at 12:13 AM 0
Share

I fixed, is it clear? sorry again for my bad english :(

avatar image WillTAtl · Nov 29, 2011 at 12:48 AM 2
Share

I was afraid you meant something like this; there's nothing you could put in a script exclusively on object D that would prevent a raycast from hitting object A, if object A is in front of object D. If object A blocks object D, object A is going to get the OnMouseOver events, not object D. If you need this kind of finer functionality, you may have to abandon OnMouseOver and implement your own system that makes manual calls to Raycast in an Update() function, either filtering what is hit by putting A, B, D, etc in separate layers and calling Raycast against those only, or by using RaycastAll and deciding which object to affect based on the set of objects that the mouse is over. That is ... rather more involved than I'm prepared to go into right now, I'm afraid.

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by milali · Nov 29, 2011 at 12:46 AM

so are you raycasting the target? And you get object A when you want object B?

Try disabling the collision meshs on those objects when you do what you want, so ignore by enable = false

Comment
superstar123

People who like this

1 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 superstar123 · Nov 29, 2011 at 04:34 AM 0
Share

Yes, this is what I need. I feel embarrassed, this is easier than my complex thoughts. Thank u 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.

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

Ignoring an object (using raycast with layers) is not working 1 Answer

Raycast still passes through even with layers! 0 Answers

Can't Ignore a Layer when raycat 0 Answers

How to create User layer that acts like the "Ignore Raycast" layer? 1 Answer

Need raycast to target child, not parent. 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