Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Brocket23 · Jan 10, 2017 at 04:22 PM · gameobject2d-platformercollider2d

Make a gameobject Trigger Trigger Colliders but not Other Colliders

I have searched everywhere I know of for this answer and as far as I can tell, it is impossible. My game has a character with a collider on it. He shoots a lazer beam with a trigger collider at the end of it so it can sense what it touches but still go through colliders. I want to make a gameobject that will stop the beam but will not stop the player. The easiest way to do this would be to make the gameobject a trigger so that the character will pass through it. But as far as I can find, a trigger can not trigger a trigger so it would not stop the beam. Please help me.

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

1 Reply

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

Answer by NinjaISV · Jan 10, 2017 at 05:06 PM

A trigger will trigger another trigger as long as one of the GameObjects that is colliding has a Rigidbody attached to it.

Another way for this that would work though would be to put the player on a separate layer that ignores collisions with the GameObjects that are blocking you from moving. This would disable all triggers between the two layers as well though.

And one more option for you if those don't work for you, you can loop through all the Colliders and make them ignore collision with the player Collider. Code snippet:

     Collider[] playerColliders;
     Collider[] ignoreColliders;
 
     void Awake () {
         //Gets all the Colliders attatched to the player
         playerColliders = GetComponents<Collider>();
         //Gets all other colliders in the scene that are active. 
         //You will probably want to replace this with another method of getting just the ones you want to ignore.
         //Or just loop through these and remove ones that don't have a certain tag, etc...
         ignoreColliders = FindObjectsOfType<Collider>();
     }
 
     void IgnoreColisions () {
         //Loops through all the colliders on the player.
         foreach(Collider playerColl in playerColliders) {
             //Ensures that the colliders attached to the player is not null and that it is not a trigger.
             if (playerColl != null && playerColl.isTrigger == false) {
                 //Loops through all the other colliders we with to ignore.
                 foreach(Collider ignoreColl in ignoreColliders) {
                     //Ensures that the colliders we have gathered are not null and that they are not a trigger.
                     if (ignoreColl != null && ignoreColl.isTrigger == false) {
                         //Tells the physics engine to ignore collisions on both of these colliders, but just for eachother.
                         Physics.IgnoreCollision(playerColl, ignoreColl, true);
                     }
                 }
             }
         }
     }

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Player movement 1 Answer

OnTriggerEnter2D and ladder won't be compatible 2 Answers

I am trying to create all elements in the scene from one script at run time. How do I detect collisions between the enemy and the coin without having to create another script for each item? 0 Answers

Ground in 2D Platformer Skewing 0 Answers

RigidBody2D mouse going through Collider ,Rigidbody2D move with mouse 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