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 Ekta-Mehta-D · Mar 29, 2013 at 06:12 AM · collisiontriggermeshcollider

Mesh Collider Does Not Working

I have a player and an enemy . I want to detect collision between player and enemy.

for that ,

        I have a player with rigidbody and mesh collider.
        -> set rigidbody iskinematic to true.
        -> set mesh collider convex to true.

        I have enemy with sphere collider.
        -> isTrigger is set to true.

Script attached to my player is here:

 function OnTriggerEnter(otherObject : Collider)
 {
     Debug.Log("Hit player");
     if(otherObject.tag == "AirCraft")
     {
         Instantiate(blastPrefab , transform.position , Quaternion.identity);
         var es : Enemy = otherObject.gameObject.GetComponent("Enemy");
         es.SetPositionandSpeed();
         Destroy(gameObject);
     }
 }

But still collision is not detected,.. What is missing ??

Please Help me.

Thanks for your support and help in advance,..

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 Fattie · Mar 29, 2013 at 08:29 AM 0
Share

just fyi as a general rtule you never use mesh colliders in video games. just use simple primitives like cube, sphere etc.

1 Reply

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

Answer by Chronos-L · Mar 29, 2013 at 06:37 AM

By this setup, the OnTriggerEnter will be called when your player is moved to your enemy; if you move your enemy to the player, nothing will happen.

Look at this page.

The player is a Kinematic-rigidbody-collider, while your enemy is a static-trigger. They will work as long as the player is the one moving. A static trigger (the enemy) moving around will not active any trigger-event, because they are supposed to be not moving (static).

If you want to move your enemy and be able to active the OnTriggerEnter(), then make the enemy a rigidbody-trigger or a kinematic-rigidbody-trigger.

Comment
Add comment · Show 15 · 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 Ekta-Mehta-D · Mar 29, 2013 at 06:53 AM 0
Share

how do i make my enemy rigidbody trigger or kinematic rigidbody trigger? i want my enemy to move and want to active trigger.

avatar image Ekta-Mehta-D · Mar 29, 2013 at 07:14 AM 0
Share

change :

I make my enemy with rigidbody. -> set iskinematic to true.

I kept my player with mesh collider -> istrigger to true and convex is also true.

Now what do i need to do??

avatar image Chronos-L · Mar 29, 2013 at 07:29 AM 1
Share

Your current setup:

Enemy ($$anonymous$$inematic Rigidbody Collider)

  • Collider

  • Rigidbody : is$$anonymous$$inematic

Player (Static Trigger Collider)

  • Collider : isTrigger

So, your player no longer have the rigidbody? If so, then the OnTriggerEnter() will be called only when the enemy is moved to the player, but not the other way around (when player is moved to enemy)

avatar image Maulik2208 · Mar 29, 2013 at 07:33 AM 1
Share

Check this out might you got some idea--->Absolute Beginners guide to Unity 3D Game Objects and Box Colliders

Cheers from INDIA......

avatar image Chronos-L · Mar 29, 2013 at 07:55 AM 1
Share

but my object is consu$$anonymous$$g more than one mesh then how do i assign ??

If it is not animated, use modelling software to model a simplified shape of the your current object. Use it as the collision mesh.

If it is animated, depending on how complex the animation is, you can still use the first solution if it is not so complex, or else you will need to built a compound collider.

Show more comments

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

13 People are following this question.

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

Related Questions

how to detect if a character has fallen / problem with triggers 1 Answer

Why is this rigidbody not activating the trigger? 0 Answers

Question on Static Primative vs Mesh Collider Performance 1 Answer

Collision Does not Detected In Mobile Android Device 3 Answers

How to add to a 3D object's length through code? 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