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
2
Question by msfredb7 · Oct 19, 2012 at 05:40 AM · collisioncolliderontriggerenterdetectionbox

how do i correctly use a box collider

For my game, i want to have a fog of war. I want the enemy to be rendered only in the lighted area. So i expanded the box collider of my player(a little cube) and i've set up the OnTriggerEnter(hit:Collider) function on my enemy. The problem : unity do not detect anything when player and enemy touch. The OnTriggerEnter funtction is never called :( pls help

Ps: both player and enemy have rigide bodies and colliders

Comment
Add comment · Show 6
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 always_beta · Oct 19, 2012 at 05:49 AM 0
Share

Is the collider of the enemy set as isTrigger?

avatar image Fattie · Oct 19, 2012 at 08:01 AM 0
Share

check out UnityGE$$anonymous$$S.com, beginner article, for a full discussion

avatar image whydoidoit · Oct 19, 2012 at 08:26 AM 0
Share

@Fattie - just as an FYI I changed it's name to Common Gotchas (to try to be less pejorative) - the link is the same

avatar image Fattie · Oct 19, 2012 at 08:47 AM 0
Share

@why .. gotchya ... i'm thinking would it be advisable to have a super easy URL for that page

like unitygems.com/gotchyas or the like ?

avatar image whydoidoit · Oct 19, 2012 at 09:43 AM 0
Share

You can use http://unitygems.com/mistakes right now. I have to play with the PHP to change it, but I was thinking of doing that.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by lil_billy · Oct 19, 2012 at 02:56 PM

ok so I dont know how you have it exactly set up however I can guess a certain number of pitfalls that you may have run in to.

-first trigger colliders only detect when the colliding object has both a SOLID collider and a rigidbody

-second in you if statement dont use "==" use other.gameObject.CompareTag ("object")

-third, never deactivate a gameobject (its almost like destroying it but it still takes up memory) instead de - enable target components that are relavant to your desired effect, in your case disable the mesh renders which you can than renable on trigger enter. DONT disable any colliders

-feel free to use as many colliders as you can, just remember there should be only one solid collider per any interactive gameObject and 99% of the time you dont want to mess with it.

Comment
Add comment · Show 3 · 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 whydoidoit · Oct 19, 2012 at 03:04 PM 0
Share

Collisions between two colliders set to isTrigger = true are registered with OnTriggerEnter - if that's what you meant by SOLID, then your first statement isn't true. If you didn't mean that then I'm missing something.

avatar image lil_billy · Oct 19, 2012 at 03:07 PM 0
Share

not in my personal experience, i've noticed that occasionally it will ignore collisions between objects with both having only trigger colliders

avatar image whydoidoit · Oct 19, 2012 at 03:08 PM 0
Share

Well that should be reported as a bug to Unity. I use this technique all the time.

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

13 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

Related Questions

how do i correctly use a box collider 0 Answers

Collision Checking 1 Answer

Trigger Spawning? 1 Answer

How to block collision between selected objects 0 Answers

OnTriggerEnter - Explosions that appear on the surface of hit object 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