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 XaeroDegreaz · Jul 21, 2012 at 05:44 AM · colliderstriggers

How can I get multiple objects with triggers, and standard collisions to work together?

I have four objects: Player (Box Collider with trigger disabled), Bullet (same as player), a ball (Sphere collider with trigger on), and a goal (Mesh Collider with trigger disabled).

I need the player to be able to trigger a ball pickup, and the ball to collide with the goal (say the player shoots the ball from an odd angle, and misses the hole), and I need the bullets to collide with the player and cause them to spin out.

I can get the bullets, players, and balls to interact properly. But, I can't seem to find the right combination to make the ball collide with the goal, and bounce off.

The strange thing is, I had all four of these objects working perfectly as they should, but somewhere along the path, I broke these things somehow.

If I turn the player into a trigger, then the ball into a non-trigger, then bullets go through the player without collision, yet the ball will bounce off the goals.

Any ideas would be appreciated.

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 XaeroDegreaz · Jul 21, 2012 at 07:33 AM

I did not resolve this by messing with the triggers, however I opted to add a second Collider to the ball. The first Collider has the trigger turned off, and collides only with the goals, thanks to the physics matrix in the preferences. The second Collider, with a trigger, is a child GameObject of the ball, and triggers when players touch it.

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
avatar image
0

Answer by Seth-Bergman · Jul 21, 2012 at 06:38 AM

Since the ball is a trigger, you should be able to add the code to the balls OnTriggerEnter function.

if(collider.tag == "goal") //etc...

If you wanted actual physics, you could turn trigger off during a shot, that should allow normal collision detection

something like:

 if(isShot)
 collider.isTrigger = false;
 else
 collider.isTrigger = true;


EDIT:

another option is to add an empty child object to the ball, and make THAT the trigger

Finally, for the full picture, go to this link, and scroll down to the bottom:

http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html

the collision matrix there will answer your exact questions..

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 XaeroDegreaz · Jul 21, 2012 at 06:40 AM 0
Share

Thanks for the input. I did think of this, however the ball also needs to be passed from player to player, and with the trigger turned off, the ball would bounce off of players.

avatar image Seth-Bergman · Jul 21, 2012 at 06:42 AM 0
Share

if you want it to have physics, you don't really need the trigger.. just use OnCollisionEnter for everything..

if that's not desired, see the first suggestion above edit: or the third..

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

How to have multiple colliders intersect without colliding with each other? 1 Answer

[Unity 4.6.1] Weird bug between 2 Colliders 1 Answer

Can I make a collider ignore only one other collider? 0 Answers

changing gravity OnTriggerEnter 1 Answer

OnTriggerEnter Multiple Collisions Activating. I tried many variations, Please help (Java) 3 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