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 stuthemoo · Jan 07, 2012 at 06:34 AM · collidertriggertag

Use trigger with player but have a collider with everything else?

Hi, I have a crate that uses a trigger to detect when the player hits it. Is there any way I can make it collide normally with all other objects? My player has a tag 'Player'. Thanks.

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 syclamoth · Jan 07, 2012 at 07:08 AM 0
Share

Yes, you just disable 'isTrigger'. Why can't you just use normal collision to detect the player?

3 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by Anxo · Jan 07, 2012 at 04:30 PM

I would nest a game Object with a collider of the same size inside the crate. Set the original collider to "isTrigger = false" and the new object inside the create to "isTrigger" So it would be like having 2 boxes, one is invisible but has a trigger that is inside the visual box. Tell the player to physics.ignoreraycast the collider on the visual box and bingo.

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 Ash-Blue · Aug 11, 2014 at 08:22 AM 0
Share

This answer is perfect if you change thing. Just tweak the layer collisions to ignore the player on the parent object. Set the child object to a detectable collision layer. No need for fancy pants raycasting.

avatar image
1

Answer by Peter G · Jan 07, 2012 at 04:53 PM

I would suggest a Layer-based ignore collision method. Place 2 colliders on top of each other. 1 is marked as a trigger, the other is solid. Create 3 layers:

 -Player (layer the player in this one)
 -PlayerOnlyTrigger (for the trigger)
 -Collider (the regular collider)

Obviously naming can be changed, but its just the idea of it.

Now go to the Physics settings, "Edit/Project Settings/ Physics" And you'll see the layer collision matrix.

  • Turn player on for EVERY layer EXCEPT COLLIDER:

  • Collider is true for EVERY layer EXCEPT PLAYER (The first bullet point should also do this for you.)

  • PlayerOnlyTrigger is false for EVERY layer except PLAYER.

Then work out your game logic as usual. In the OnTriggerEnter() you don't have to worry about checking if its the player either because you can only collide with the player anyway.

Comment
Add comment · Show 2 · 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 centaurianmudpig · Jan 14, 2012 at 07:42 PM 0
Share
  • to this. I would Up Vote but it won't let me :/

avatar image Johat · Aug 11, 2014 at 11:17 AM 0
Share
  • (if I could!)

This is definitely the neatest way to do this.

avatar image
0

Answer by WoodyDRN · Aug 08, 2012 at 10:09 AM

Good posts! I had this problems too, the solution I used was to:

1) Create a MESH Collider on the gameobject with isTrigger DISABLED, then the gameobject is solid, and you can't walk through it.

2) Then I added a BOX Collider on the same gameobject and set isTrigger ENABLED.

Now the BOX collider will trigger any script with functions OnTriggerEnter and OnTriggerExit.

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

9 People are following this question.

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

Related Questions

Undefind tag? 0 Answers

Check Trigger Collision's Name/Tag 1 Answer

Reaching a gameobject from its collider 3 Answers

Collision, tags, and triggers 1 Answer

Why isnt OnTriggerEnter Tags working. 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