• 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 Majatek · Apr 22, 2011 at 08:30 AM · oncollisionenterdisablechildren

How to disable children triggering the collision event of parent.

Using "function OnCollisionEnter(collider:Collision)" returns a trigger with both my vehicle's body AND the wheels when the entire object collides with the terrain - Which is not what I want, because on collision with a solid, I'm reducing the friction of the wheels. If the function triggers because the wheels collide with the ground (and are constantly in contact with the terrain), it ruins what I'm trying to achieve and my vehicle ends up sliding all over the place, permanently.

Is there any way to disable the children from triggering the event? I've got the Javascript running in my parent object (that's at the top of the hierarchy - Vehicle wheels stored inside).

As a side note, I've grouped the terrain colliders and the wheel colliders into their own layers, but I have no idea how to utilize them, if I could.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Teare · Apr 23, 2011 at 08:30 PM

you want to add tag to the body, called "Body" or something and then filter it out in the collision function using:

function OnCollisionEnter (collider:Collision){
    if(collider.tag == "Body"){
        //your function here

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Disabling audio Listener on the child of a newly instantiated gameObject? 0 Answers

Enable/Disable children / group of objects 0 Answers

Disabling Script on many Objects one at a time. 1 Answer

Getting an objects Children 1 Answer

How do I mount a Vehicle? 4 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges