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
1
Question by reptilebeats · Jan 15, 2012 at 11:10 PM · triggersignore

ignore triggers

looking for a simple way to say i want this trigger to ignore certain objects. so say i have a human with colliders on him which are triggers and one of them activates something when it hits or gets hit. the only problem though is if one of these triggers touch each other it activates the other thing..

i was going to say if this trigger hits the certain thing then it activates but there are a lot of different things in my game that activates this

so basically need a bit of code which simply says ignore this object/trigger..

i know how to ignore collisions but this is no good as it adds unwanted movement to the character and extra weight.

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

3 Replies

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

Answer by Kryptos · Jan 15, 2012 at 11:29 PM

To achieve that you have to use a good combination of layers. And set their relation regarding Physx properly. See http://unity3d.com/support/documentation/Components/Layer%20Based%20Collision%20detection.html

Note that you can change the layer of any object (and child object) at runtime so they might fall into one or another category (colliding, not-colliding...).

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 reptilebeats · Jan 15, 2012 at 11:38 PM 0
Share

i will have a look at this and compare which is better, its probably more efficiant than above. have to see with the next part of the game. basically when my trigger does hit something i want all my triggers to turn back into colliders..

avatar image
1

Answer by reptilebeats · Jan 15, 2012 at 11:29 PM

got it its

Physics.IgnoreCollision(collider, transform.gameObject.Find("").collider);

if anyones got anything better let me know

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 reptilebeats · Jan 15, 2012 at 11:31 PM 0
Share

i forgot need to use function start(){}

avatar image
0

Answer by aldonaletto · Jan 15, 2012 at 11:39 PM

You can place objects in different layers and define the Collision Matrix, so objects in one layer can collide only with objects in other specific layers, but more frequently you just use special tags to identify the objects that can be activated, collected etc.:

function OnTriggerEnter(other: Collider){ if (other.CompareTag("Switch")){ // use CompareTag... // call Activate(true) in the other object's script other.SendMessageUpwards("Activate", true); } if (other.tag == "Bonus50"){ // or compare the string directly Inventory.bonus += 50; // count points in a static variable... audio.PlayOneShot(bonusSound); // play the appropriate sound... Destroy(other.gameObject); // destroy the picked object } }

function OnTriggerEnter(other: Collider){ if (other.CompareTag("Switch")){ // call Activate(false) in the other object's script other.SendMessageUpwards("Activate", false); } } This way you can take the appropriate actions for each kind of object.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can Physics.IgnoreCollision disable OnTrigger... events? 2 Answers

Colliders overlapping with trigger colliders 1 Answer

A child component is triggering its parent collider. 1 Answer

Trigger still works when disabled 1 Answer

Get Object, Trigger Attached Method,Trigger method on collider script 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