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 jaja1 · Dec 11, 2014 at 05:32 AM · c#collisionrigidbodytrigger

Collision triggers do not work on child gameobject

I have an issue with an OnTriggerStay method in a child gameobject. Here is the system I have implemented:

Player (parent): 1. Ground item grabber collider (child) -> kinematic rigidbody, OnTriggerStay detection 2. Weapon Collider (child) -> kinematic rigidbody, OnTriggerStay detection

I am also using layers to separate my colliders. I ensured the "item on the ground" is on the same layer as the "item grabber" and the layer is enabled in my physics options.

I have also tried this system without kinematic rigid bodies, disabling one of the children, placing a rigid body on the parent ONLY and I also tried OnTriggerEnter.

The Ground Item grabber child fails to work none the less and the weapon collider works without fail. Why is that so? Here is the code on the item grabber collider:

 public class player_grab_collider : MonoBehaviour 
 {
 
     MukizuServer _Mukizuserver;
 
     // Use this for initialization
     void Start ()
     {
         _Mukizuserver = GameObject.Find(".MukizuServer").GetComponent<MukizuServer>();
         rigidbody.isKinematic = true;
     }
         
     void OnTriggerStay (Collider other)
     {
         Debug.Log("...");
         if (player_controller.canClaim && other.gameObject.tag == "Ground Item")
         {
             _Mukizuserver.SendItemClaimReq(other.gameObject.name);
         }
     }
 
 }


The Debug.Log is not even called meaning absolutely nothing was detected. Even using other trigger detection methods like OnTriggerEnter it does not work. And yes, the trigger on the "ground item" is enabled. I tried adding rigid body to that as well.

Comment
Add comment · Show 5
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 jaja1 · Dec 12, 2014 at 12:35 AM 0
Share

bump.......

avatar image MidgardDev · Dec 12, 2014 at 12:50 AM 0
Share

The trigger should be activated by the player by entering somewhere? Do you use the built-in Player Controller?

avatar image jaja1 · Dec 12, 2014 at 07:06 AM 0
Share

@$$anonymous$$idgardDev no I don't. And the ground item is an object that spawns when say a monster dies. When the player passes over the item, their grabber object is supposed to set the trigger off and allow the player to pick up the item.

avatar image MidgardDev · Dec 12, 2014 at 08:56 AM 0
Share

@jaja1 I would recommend you to put a rigidbody on your player, then handle the trigger from him, ins$$anonymous$$d of what you're doing.

So, just put a rigidbody on your player, then leave the trigger as a box collider with the trigger option ticked and without anything else, that would call the OnTriggerStay function definitely.

avatar image jaja1 · Dec 12, 2014 at 05:47 PM 0
Share

@$$anonymous$$idgardDev I tried your set up, still does not work. If you want to see my current set up look under the second answer, I made screenshots.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by tanoshimi · Dec 11, 2014 at 06:57 AM

What sort of colliders do your "Ground item grabber collider (child)" and "ground item" have? Note that two mesh colliders cannot collide with each other unless they are convex (documented here).

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 jaja1 · Dec 11, 2014 at 07:43 PM 0
Share

The collider on the ground item is a simple box collider. The collider on the grabber object is a capsule collider. I checked and I am sure the two intersect at some point.

avatar image
0

Answer by FairGamesProductions · Dec 11, 2014 at 11:01 AM

Your ground item should NOT have the trigger enabled, it should be a simple collider with a RigidBody component. A trigger will NOT trigger another trigger...

And your grabber object, should be a trigger WITHOUT a RigidBody component, since there is no actual need to it.

Comment
Add comment · Show 6 · 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 jaja1 · Dec 11, 2014 at 07:44 PM 0
Share

I tried your method but unfortunately no luck. I've been through numerous combinations of rigidbodies and triggers but nothing seems to work yet. This used to work when the collider was attached to parent object. I made it a child because I wanted separate scripts running for the grabber collider and the player's weapon collider.

avatar image FairGamesProductions · Dec 12, 2014 at 08:50 AM 0
Share

Can you make a print screen of your setup? I want to see the colliders in the editor.

avatar image jaja1 · Dec 12, 2014 at 05:50 PM 0
Share

@FairGamesProductions Here is my full set up. The parent "playerPrefab" has no rigid body attached to it.

1.png (87.7 kB)
2.png (25.5 kB)
avatar image jaja1 · Dec 12, 2014 at 05:50 PM 0
Share

Continued....

3.png (93.3 kB)
4.png (31.3 kB)
avatar image jaja1 · Dec 12, 2014 at 05:51 PM 0
Share

Continued.......

5.png (100.4 kB)
6.png (37.6 kB)
Show more comments
avatar image
0

Answer by jaja1 · Dec 12, 2014 at 11:23 PM

Not sure why, but I used a box collider instead fort he grabber object and it seems to have worked. If anyone else has some input on this let me know.

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

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

Related Questions

How to detect in grid of objects if one is destroyed while beside adjacent objects without rigidbody? 1 Answer

Any way to ignore collision between rigidbodies and colliders/character controllers? 1 Answer

Need help with scripting bug fix. pleease 0 Answers

Rigidbody.SweepTest Hit Trigger Colliders 0 Answers

Is it possible to detect different colliders with one script ? 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