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 Teku-Studios · Dec 19, 2014 at 07:02 PM · triggerscollisionsignore

Can Physics.IgnoreCollision disable OnTrigger... events?

Here's my situation: I have a trigger that acts as "dark area" so that every sprite that enters it has its color light (V value - HSV) changed to give the player the feeling of entering a shadow zone. The trigger has a generic script that I use a lot throughout the game, and it affects every sprite inside the trigger.

I use the OnTriggerStay() method because I want to smooth the sprites' color change depending on their Xpos (darker the closer they are to the centre of the trigger, and lighter the farther they are from it). Due to perspective issues, I want the main character to not send the OnTrigger Enter, Stay and Exit events just for one specific trigger, and I can't disable it since there is another character in it who does need to be endarked at te same time. I've tried using Physics.IgnoreCollision(trigger, player), but the trigger functionalities are still intact and working.

Due to in-game limitations, I can't change the physics collision graph since that kind of trigger is a very specific one and modifying that now would break countless scenes. Is there some way I can achieve this without changing much code?

*NOTE: Althoug it is a sprite-based game, it is a full 3D environment and we are working with PhysX, not Box2D, that's why I'm dealing with Physics instead of Physics2D.

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

2 Replies

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

Answer by Mmmpies · Dec 19, 2014 at 08:11 PM

Can't you just check what's colliding and apply if the object is one but not the other?

Might need to know more about your game to advise but it'd be easier doing it that way.

If you need the object the character collides with to be instantiated lots of times there are still ways you can reference a specific instance and set a public bool to tell that instance is now this special collider and therefore acts differently for character X than it does to character Y.

Sorry if I've misunderstood the question.

EDIT:

And I think I did! was thinking triggers. What about collider.enabled = false;

EDIT 2:

And you could maybe do that with a trigger. Slightly larger trigger area if the trigger == character to pass collider.enabled = false; if not collider.enabled = true;

It also looks like you should be able to fix it with your method, but it needs adding each time.

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 Teku-Studios · Dec 20, 2014 at 07:06 PM 0
Share

I simply added a bool and a 'If' check, and that solved it. The problem was that it is a generic script that we use throughout the game but we wanted that one to work slightly different without just making a new script with 99% the same code.

What I did is add a bool called 'ignore$$anonymous$$ainCharacter' set to false by default and, if true, the OnTriggerStay method checks if the colliding object's tag is 'Player' and ignores it. Not exactly the best solution, but works there without breaking our setup for the entire game. Thanks!

avatar image
0

Answer by Teku-Studios · Dec 19, 2014 at 08:11 PM

Never mind, I already solved this problem by setting a very simple flag on the shadow script configurable from the Inspector.

Either way, is there a way to disable OnTrigger events somehow between 2 specific colliders with something as simple as Physics.IgnoreCollision()?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

ignore triggers 3 Answers

How to use CollisionIgnoreManager.cs 2 Answers

OnTriggerEnter called much less often after a player respawn? 1 Answer

Colliders overlapping with trigger colliders 1 Answer

Ignore collisions with self but still trigger with self 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