Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 JustinTheSwift · Apr 25, 2017 at 02:34 PM · rigidbodyboxcolliderbox collider

Box collider won't collide as a child?

I've got a player, who carries a weapon (both of which are just 1x1x1 cubes at the moment). The weapon is a child of the player. Both the weapon and the player have a box collider.

I have another cube which is my enemy. The enemy has a box collider which is a trigger. The enemy's script logs a notification on any intersection with the weapon.

Or it should.

For some reason, my weapon won't collide with anything. It goes through walls, enemies, etc.

I have tried making my weapon independent - no longer a child of the player, but a sister to it - and by giving it a character controller and adding my player script to it, I can run my weapon around the field and it will collide with anything, and also will log intersections with the enemy.

Seeing that this worked, I also tried adding a character controller to my weapon once I had restored it to it's rightful place as a child of the player. It didn't help.

So my question is this: what is it about being a child or not having a script that causes my weapon's box collider to lose it's all-important collision ability?

UPDATE: I've added a rigidbody to the weapon. When "is kinematic" is checked off, the weapon behaves in unexpected ways. When "is kinematic" is on, I get the trigger detection I was looking for, but the weapon still passes through walls (which I would prefer not to have). And why should I need a rigid body to make a collider work? It seems like simple collisions and complex physics are two distinct things...

Comment
Add comment · Show 6
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 sadowlight123 · Apr 25, 2017 at 09:21 PM 0
Share

all i can help with is that every time you want to do the OnTriggerEnter you need to have two colliders with at least one of them having a rigidbody and one has the trigger box checked

avatar image sadowlight123 · Apr 25, 2017 at 09:22 PM 0
Share

did you make sure your weapon didn't have the trigger option checked on it ?

avatar image JustinTheSwift sadowlight123 · Apr 26, 2017 at 11:29 AM 0
Share

Thanks for the input. As you see from my update, I added a rigidbody which enabled my trigger (which is on the enemy, not the weapon) to work. The only issue now is that the box collider doesn't collide with walls and such. While this is a problem, it's not a big problem, so I've pretty much just decided to move on with development without worrying about it, but this is still a curiosity...

avatar image sadowlight123 JustinTheSwift · Apr 26, 2017 at 01:49 PM 0
Share

ah yes , to solve this kind of problem you usually put on the same object two colliders one big collider that is the trigger and one smaller collider that make the enemy collide into walls

avatar image santiandrade · Apr 26, 2017 at 02:41 PM 0
Share

Hi @JustinTheSwift! The official definition of the function "OnCollisionEnter(...)" says:

Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached.

So when you want to use collision events (Unity's physics), it is always required that one of the objects must have a rigidbody.

avatar image Glurth · Apr 26, 2017 at 07:27 PM 0
Share

"but the weapon still passes through walls (which I would prefer not to have)" If you would like the weapon to have a rigid body, it should NOT be a child of the player. Ins$$anonymous$$d, connected it with a FixedJoint (or SO$$anonymous$$E kind of joint.) This will connect the two rigid bodies, using physics. So, when say, moving forward with a spear poking out in front; when the weapon hits the wall, the impact force will be felt by BOTH the weapon AND the player (AND any OTHER objects connected by joints.)

0 Replies

· Add your reply
  • Sort: 

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 hide a Game Object on collission? 2 Answers

Rigid body not colliding with box collider. 1 Answer

Rigidbody -- Box Collider Collision Detection 1 Answer

My 2 Objescts doesnt collide 1 Answer

Is it possible to scale one face of a box collider?? 2 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