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 /
This question was closed May 11, 2013 at 11:47 PM by Ochreous for the following reason:

Question is off-topic or not relevant

avatar image
1
Question by Ochreous · May 11, 2013 at 08:48 PM · collidertrigger

Toggling Is Trigger on box collider causes it to not collide

Hi everyone, I have a script that uses the OnTriggerEnter function.I have the script attached to a cube and set for Is Trigger.But for some reason the collider isn't working properly and objects pass right through it. Any idea what is up?

Comment
Add comment · Show 1
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 RGBStudios · May 21, 2021 at 05:29 AM 0
Share

I was struggling with this for a while and adding another collider wasn't working for me (the character was still falling through). I also tried making one collider smaller and still nothing. I found on this website https://unitygem.wordpress.com/common-unity-gotchas/ the answer is to just use onCollisionEnter if you have a collider, and onTriggerEnter if you don't have a collider. I removed the duplicate collider, unchecked isTrigger, and added the OnCollisionEnter2D function (my game is 2d) and it works perfectly!

2 Replies

  • Sort: 
avatar image
5
Best Answer

Answer by EION Technology · May 11, 2013 at 10:30 PM

Hello. Is Trigger in unity disables the function of the collider and turns it into a passable trigger. (When you think about it, how would OnTriggerEnter / OnTriggerExit work if it didn't allow you to pass through the collider?) The best way to do the Is Trigger on an object is to add another collider component to the GameObject that you want to be an event trigger. So in other words, the object itself will still have the collider that stops the player, and the Is Trigger collider component will act as the trigger for your GameObject. Make sure that you have the Trigger Collider a little larger than the GameObject itself. Hope this helps.

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 AdamHalo · Dec 21, 2014 at 09:38 PM 0
Share

Lifesaver. I've wasted several hours trying to solve this issue. The solution, as ever, is simple.

avatar image
0

Answer by Dreamora · May 11, 2013 at 09:28 PM

If you set it as a trigger, then it will no longer do collisions. It will only trigger the trigger events (enter, stay, leave) This is meant to be like this as you use triggers for cases where you want to detect presence of objects in an area. if you want a physical reaction, then do not mark the object as a trigger but leave it as a collider and it will work just fine.

Comment
Add comment · Show 4 · 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 Ochreous · May 11, 2013 at 09:41 PM 0
Share

I have my cube with Is Trigger set to false but my script isn't working. Do I need to change my script so it's specifically for character controllers?

 using UnityEngine;
 using System.Collections;
 
 public class PlayerDetect : $$anonymous$$onoBehaviour {
 public bool somebool;
 void OnTriggerEnter (Collider Player) {
 if(Player.gameObject.tag=="Player"){
 somebool = true;
         }
     }
 }
 
 
avatar image Ochreous · May 11, 2013 at 10:52 PM 0
Share

I edited my script so it would work for character controllers specifically.But now I can't get the script to detect when the player collides with the cube. Any idea why it's not detecting the player?

 using UnityEngine;
 using System.Collections;
 
 public class PlayerDetect : $$anonymous$$onoBehaviour {
 
     void OnControllerColliderHit(ControllerColliderHit playerCollider){
      if(playerCollider.gameObject.tag == "Player"){
       Debug.Log("Hit Player");
      }
    }
 }
 
avatar image Dreamora · May 12, 2013 at 05:12 AM 0
Share

This function will not work with triggers as CharacterController is no rigidbody and operates partially outside the physics environment I fear

avatar image jinchong · Jul 28, 2015 at 10:02 AM 0
Share

This awesome video shows cases for which collision may not occur...

http://youtu.be/Bg73o9JH53c

Follow this Question

Answers Answers and Comments

17 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

Related Questions

Check if another object exist in a position before respawning 1 Answer

Player character walks through terrain and objects 2 Answers

Problems when i have multiple enemies on the same scene C# 1 Answer

Triggering door animation with collider 2 Answers

Can't click gameobject when over another trigger? 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