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 zero1024 · Jun 12, 2021 at 12:06 AM · colliderstriggerscollision issues

Why my "Is Trigger" box colliders are physically colliding with other colliders?

Hi all and thank you for your time.

In my scene, I have terrain trees with Capsule Colliders and other GameObjects some with Box Colliders, some with Mesh Colliders.

All of them are colliding with my Player, my AI enemy character and the bullets from weapons. (all of them with a Rigidbody and a Capsule Collider)

I tried adding another collider on all "flammable" objects that I have in my scene, to trigger a fire effect based on collision triggers through a script. (For example my terrain trees and some GameObjects like tree stumps)

To do that, I've added an extra Box Collider with "Is Trigger" checked.

The script worked but to my surprise, all the new Box Collider triggers are acting as normal colliders! Everything from my character to my bullets are now colliding with the Box Colliders that have "Is Trigger" checked instead of the original Capsule or Mesh colliders the objects have!

At first, colliders and triggers were on the same child object but I've also tried adding the trigger to another child object, tried to add the trigger on a child of the child with the collider, tried adding the trigger on the parent object but always the same thing, the trigger is colliding as if it's not a trigger at all.

As a last resort, I tried adding the triggers on a different Layer called Fire and then unchecking EVERY other Layer in the "Layer Collision Matrix" to disable collisions with everything on the scene.

The magical Box Colliders with "Is Trigger" are STILL colliding with everything completely ignoring the Layer Collision Matrix!

Needless to say that I have no clue as to what is the problem and what I should check next.

My project is a 3D project and I'm using the built in renderer (no URP or HDRP) with Unity version 2020.2.2f1
(So I guess the collision matrix of the Physics 2D has no effect, right?)

Any help from you will be highly appreciated.

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 DenisIsDenis · Jun 12, 2021 at 02:19 AM 0
Share

Have you tried adding other types of colliders with an active isTrigger?

avatar image zero1024 DenisIsDenis · Jun 12, 2021 at 10:49 AM 0
Share

Thank you for your reply. Unfortunately the fire script isn't $$anonymous$$e, it's a unity store asset that requires the box colliders and it doesn't work with other types of colliders. So even if for some reason other types of colliders do work properly, it won't solve my problem. I will try it though, just because I'm really curious and reply back with the result!

avatar image zero1024 DenisIsDenis · Jun 12, 2021 at 11:11 AM 0
Share

Yep! Still the same with Capsule Collider set as "Is Trigger". It collides physically, confirmed! I've also tried to disable the Mesh Collider that is not set as "Is Trigger" and left only the trigger on a child object, just to check if collision still happens even thought there are NO active colliders on the GameObject and yes. With ONLY the one Is Trigger capsule collider on the object, it still collides physically! I'm thinking, it could be a raycast thing from a script that I'm missing, but with the collision matrix completely disabled, even raycasts shouldn't work right?

avatar image DenisIsDenis · Jun 12, 2021 at 12:19 PM 0
Share

To disable raycast collisions on isTrigger objects in Physics2D:

  Physics2D.queriesHitTriggers = false; // write this in Start()
avatar image logicandchaos · Jun 12, 2021 at 01:09 PM 0
Share

can you show more info? Your gameObjects in the inspector and your code?

1 Reply

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

Answer by zero1024 · Jun 12, 2021 at 05:46 PM

I finally solved the problem.

To anyone with a similar issue, here is what was happening:

It was actually a 2-part problem.

Part-1: The terrain trees On my prefab trees I had 2 colliders, one was a capsule collider with actual collision enabled and a box collider that was checked as trigger.

When Unity is placing trees on the terrain, all of them become part of the terrain mesh (the trees are not GameObjects on the terrain) and through that process, Unity is "reading" all the colliders on the tree prefab and using them as colliders on the terrain tree.

On that process Unity doesn't care if a collider is checked as trigger, it will use all colliders on the prefab as non-triggers and that is why my character, AI & bullets are colliding with the trigger.

To solve the issue, I disabled the child object with the trigger and added a very simple script on the prefab that will SetActive(true) the child object on Start. That way the terrain will not use the box collider at all, my fire script will replace the terrain tree with the prefab on run-time to start the fire effect and when that happens, the script will enable the trigger.

Now you may be wandering, how does this fix the collision problem with the GameObjcets? Here is where part 2 comes in.

Part-2: GameObjects I use a "Third Person Template" Asset on my project for the Player and the AI, so it was difficult to find out if a script was raycasting, causing all this. To make sure that no collision was enabled, I disabled everything in the Layer Collision Matrix on the Fire layer and I thought that was it.

However after reading MelvMay's reply above that "Queries have their own LayerMask filter arguments" I tried to find a way to disable raycast collisions as well.

So in the end it was very simple, I used "Physics.queriesHitTriggers = false;" to stop raycasts from interacting with the trigger and everything worked as expected! It was indeed a script that was stopping my characters and my bullets, not an actual collision.

After that I tried to simply change the Layer to "2: Ignore Raycasts" and it's also working as expected.

Thank you all for your time and invaluable help!

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

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

123 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

Related Questions

Trigger with get key down problems 0 Answers

number of colliders inside a trigger. 2 Answers

physics.OverlapSphere colliders 1 Answer

Is there a way to add different trigger to each specific game Object 0 Answers

OnTriggerEnter/Exit work in an unexpected way 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