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
0
Question by XraZerTR · Apr 12, 2020 at 12:30 PM · gameobjecttriggermousedown

MouseDown Triggered by Another GameObject

I have bomb and brick game objects. Sometimes, when i click a brick, the mousedown() event of bomb object is called for no reason. The mouseDown() event of the Brick does not being called.I am pretty sure that the script is attached to only the Bomb object. And this does not happen always.

 public class Bomb : MonoBehaviour
 {
 //this function is being triggered when another GameObject is clicked, and the onClick function of the right object is not being triggered. this not happens always.
     private void OnMouseDown()
     {
        // do stuff()
     }
 }

Video: https://youtu.be/exOrb72Od_w As you can see, when a brick is clicked, the nearby bricks with the same color will be eliminated. When the bomb element is clicked, nearby elements (with 1 distance) is being destroyed, regardless of their color. But in the 00:12, I clicked the green brick object, but the onMouseDown() of bomb object is being triggered.

And the bomb prefab's size look OK. alt text

screen-shot-2020-04-12-at-171938.png (215.6 kB)
Comment
Add comment
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 Reply

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

Answer by JustAbhi · Apr 12, 2020 at 12:48 PM

hi @XraZerTR Sorry I misunderstood the question.

have you tried tweaking the colliders of the prefab it might be a bit large?

Comment
Add comment · Show 6 · 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 XraZerTR · Apr 12, 2020 at 12:56 PM 0
Share

I don't get it. I'm using Unity's On$$anonymous$$ouseDown() function on a script that only attached to Bomb objects.

avatar image JustAbhi XraZerTR · Apr 12, 2020 at 12:59 PM 0
Share

Thats the problem, the engine sets the function true irrespective of where you are unless you tell it to

avatar image JustAbhi · Apr 12, 2020 at 01:05 PM 0
Share

@XraZerTR Hope this solves your problem.

avatar image XraZerTR · Apr 12, 2020 at 01:26 PM 0
Share

$$anonymous$$y friend I know you're trying to help but that's not the issue. In the video guy uses Input.get$$anonymous$$ouseDown() function to capture clicks and uses Raycast to figure out which object is clicked. However, I use on$$anonymous$$ouseDown() function described here https://docs.unity3d.com/ScriptReference/$$anonymous$$onoBehaviour.On$$anonymous$$ouseDown.html the function is triggered whenever the gameObject attached to script is clicked.

avatar image XraZerTR · Apr 12, 2020 at 02:24 PM 0
Share

@JustAbhi yeah i thought about too but the bomb's size looks OK, i've uploaded a picture in the question.

avatar image XraZerTR · Apr 12, 2020 at 05:22 PM 0
Share

Yeah, I found it. I don't know why, but my bomb object's box collider's width and height set to 5.12, setting them to 1 solved the issue.

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

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

Ai trigger 0 Answers

How to set a gameobject with a mouse click 1 Answer

How I can do to make the objects do not take a lot of space in the game? 3 Answers

about loop transforming objects 1 Answer

What would you do with essential items? 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