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 barker_s · Aug 24, 2013 at 04:44 PM · collisionbugcollision-error

Collision triggered without objects touching - problem

I have a game, where the player is being chased by a monster in a corridor system. If the monster collides with the player, it's game over and it's been working ok so far, but I've decided to add a few more monsters and see how they behave. So I have put the player object on top of my corridors, so it wouldn't collide with my monsters and I could observe their behavior. After about a minute, however, collision has been triggered, even though the monster was halfway across the level. Here's the pic (player's on the left, on top of a white cube, the monster is on the right in a corridor):

alt text

Weird thing is, it seems to work fine when the player is inside the corridor system. The problem only arises when he's outside.

Here's my collision code (nothing extraordinary here):

     void OnTriggerEnter(Collider other)
     {
         
         if(other.tag == "PlayerDamageHandler")
         {
                         //DO STUFF HERE
 
             //FOR DEBUG ONLY
             Time.timeScale = 0;
             this.gameObject.transform.Rotate(new Vector3(0, 0, 180));
             
         }
     }

I've checked all the objects, and there are no other objects with that tag. I'm really stumped on this one, so any help is appreciated.

bug.png (91.0 kB)
Comment
Add comment · Show 4
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 TSRajesh · Aug 24, 2013 at 05:28 PM 0
Share

The logical next step is.. to print the name of the colliding object. Your issue is just the collision getting triggered? or does it also pass the 'tag == "PlayerDamageHandler"' condition? If former, I would expect it could trigger with the wall / corridor and whatnot..

avatar image barker_s · Aug 24, 2013 at 06:47 PM 0
Share

Unfortunately, it passes the check, even though it's pretty far from my player object. I'm gonna run a few more tests and I'll get back to you.

avatar image x_ivan_x@live.nl · Aug 24, 2013 at 06:58 PM 0
Share

Try OnCollisionEnter ?

avatar image barker_s · Aug 24, 2013 at 07:38 PM 0
Share

I will. In the meantime, I'll dump some info from my debug log:

 Collision with: AdvancedPlayer
 Enemy's coords: -5.904749 -2.748328 -14.80869 
 Player's coords: 0.05429918 4.256039 1.24882 
 Distance between entities: 18.50446
 Player bounds: Center: (0.1, 5.8, 1.2), Extents: (0.8, 1.5, 0.8)
 $$anonymous$$onster bounds: Center: (-6.1, -1.4, -15.4), Extents: (1.5, 1.5, 1.5)
 $$anonymous$$onster bounds intersect: False
 Player bounds intersect: False

So it seems that their bounding boxes aren't even intersecting, yet the collision somehow occurs. I'll try OnCollisionEnter and get back with the results. Thanks for your input so far.

1 Reply

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

Answer by barker_s · Aug 24, 2013 at 11:00 PM

Ok, I've managed to fix this, although in a rather hacky way.

I used the fact, that during this "phantom collision" there's no points of intersection between my colliders, so I've added another conditional that checks if there's an intersection:

     void OnTriggerEnter(Collider other)
     {
  
        if(other.tag == "PlayerDamageHandler" && this.collider.bounds.Intersects(other.bounds))
        {
                         //DO STUFF HERE
  
        }
     }

It didn't really answer my original question (why would there be a collision event fired without actual collision?), so I'll have to do some more digging about it, but at least I've been able to achieve peace of mind for today ;) .

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 KarlKarl2000 · Jul 21, 2017 at 03:26 AM 0
Share

I had the same problem!! But I couldn't use your solution as "this.collider.bounds.Intersects(other.bounds)" doesn't work anymore

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

18 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

Related Questions

CapsuleCast colliding improperly 2 Answers

3D Particles collision don't work 0 Answers

How do I stop my enemy from falling over? 3 Answers

OnMouseDown() won't work unless gameObject's 2DBox Collider - ‘Is Trigger’ is toggled on/off mid-game in editor. 0 Answers

Collider colliding with itself 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