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 filler03 · Nov 13, 2012 at 09:14 PM · collidermouse-over

OnMouseOver is not working properly?

I have objects in my scene that detect when the mouse is over their collider. All the objects are exactly the same. It works when I am close enough to the object but when it is too far away it doesn't detect the cursor. They have huge colliders on them so I don't think the problem has to do with the size of those. Any ideas for why this could be?

Comment
Add comment · 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 Seth-Bergman · Nov 13, 2012 at 09:23 PM 1
Share

there is probably another collider in the scene that is getting between the camera and the On$$anonymous$$ouseOver object

avatar image sparkzbarca · Nov 14, 2012 at 07:00 AM 0
Share

how are you detecting them being over it?

On$$anonymous$$ouseOver is a GUI function not a general gameobject function.

If its custom code your going to have to post.

if its a raycast try sphere casting ins$$anonymous$$d so you get a bigger radius.

avatar image venhip · Nov 14, 2012 at 07:39 AM 0
Share

@sparkbarca I have used On$$anonymous$$ouseOver for detecting on gameobjects before and it can be quite effective in 3d menus and the like.

avatar image sparkzbarca · Nov 14, 2012 at 05:08 PM 0
Share

yea just read the docs didnt notice it worked with colliders in general as well.

are the objects your mousing over standing straight up?

maybe the angle between the mouse which is straight up and the object which may be canted makes it appear they are over eachother but when unity raycasts to check it isn't.

Close up the difference is less noticable.

When you are close up can you aim near the edge and still be over it but not get a mouseover true?

avatar image filler03 · Nov 15, 2012 at 05:41 AM 0
Share

Seth was right there was another collider that i forgot about. What would be the best way to detect the mouse on an object behind another collider?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by venhip · Nov 14, 2012 at 07:42 AM

Do you have your mouse locked to the centre of your screen? I've had problems with that in the past but if not then it's probably best to do a raycast or spherecast from a camera. It will give you more options later on.

http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html

http://docs.unity3d.com/Documentation/ScriptReference/Physics.SphereCast.html

check there for more info on how to use them. If you want to detect for an infinite distance you can set the distance of the raycast very high, higher than you'll ever need - or perhaps someone else knows a way of carrying it on forever (might kill your cpu though)

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 sparkzbarca · Nov 14, 2012 at 05:03 PM 0
Share

ray cast does go on forever it is by default to the length

mathf.infinity (not infinite but yea its really big)

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

12 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

Related Questions

Internal collisions 1 Answer

Getting continuos collision AND collision without a barrier 0 Answers

Why does a prefab instance not collide, when prefab collisions work fine? 0 Answers

OnCollisionEnter2D is not working 0 Answers

AddTorque vs Colliders 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