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 vectrino · Jun 30, 2012 at 02:20 PM · collisionrigidbodytrigger

Detect 2 non kinematic triggers?

Hello! I am making a SHMUP game, and I want the player to lose a life if it collides with an asteroid object. Unfortunately, both the asteroid and the player are triggers (the player doesn't have to be a trigger, but I can't get it to collide when it isn't either), so I can't figure out how to get the 2 triggers to collide. I read that if they have rigidbodies 2 triggers can collide, so I added rigidbodies to both (with gravity disabled), but it's still not working. Here is the code I have attached to my player's body:

 #pragma strict
 var lives = 3;
 
 function Update ()
 {
     if(lives < 1)
     {
         Application.LoadLevel ("GameOver");
     }
 }
 
 function OnTriggerEnter(other: Collider)
 {
     if(other.gameObject.tag == 'Enemy')
     {
         lives -= 1;
     }
     Destroy(gameObject); //this is only here to test if the collision is working at all and it's not a problem with the above if statement, it's not going to be in the game. It still isn't working
 }
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

Answer by Linus · Jul 04, 2012 at 05:43 AM

Some things to check

First, make sure the enemy is tagged "Enemy". Then make sure once more

When you tested with istrigger turned off, did you change:

 function OnTriggerEnter

to

 function OnCollisionEnter


The depth, if this is a 2D style game, make sure the object don't pass each other on the depth.

Lastly, if you provide the project (or a video) I am willing to help more. Did a similar project when first starting.

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 Piflik · Jun 30, 2012 at 03:17 PM

I never had a problem with two triggers not seeing each other, unless they are both mesh colliders not set to convex. Could that be the case?

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 vectrino · Jun 30, 2012 at 09:10 PM 0
Share

Nope, one is a mesh set to convex and the other is a box collider. Want to see my project?

avatar image
0

Answer by Berenger · Jun 30, 2012 at 09:24 PM

As you said you added rigidbody for this issue only, I assume you're moving those objects with Translate or position += something. That kind of movement cannot raise collision event, unless it's to move an object with a rigidbody kinematic into an other object with a rigidbody NOT kinematic.

You should use AddForce.

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 Piflik · Jun 30, 2012 at 10:35 PM 0
Share

They ignore collisions, but they should still trigger the function. In my game I move everything directly with transform.position and triggers work just fine.

avatar image vectrino · Jul 01, 2012 at 01:59 PM 0
Share

I do use addforce.

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

7 People are following this question.

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

Related Questions

RigidBody - GameObject moves but mesh stays! 1 Answer

The trigger enter detect fast moving object more accurate 2 Answers

Trigger between 2 kinematic bodies not firing? -1 Answers

OnTriggerEnter is not working! I have tried absolutely everything I can think of. 1 Answer

Rigidbody Trigger Collider vs. Static Collider no OnTriggerEnter message 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