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 Hamesh81 · May 24, 2013 at 12:22 PM · raycastraycastingparentchildtag

How can I differentiate between colliding with an object or its child?

alt text

When I fire an arrow (red arrows) into another other object (blue cubes) it checks the object's tag via raycast and then parents itself to that object if the tag matches (left cube). The problem is that after the parenting, the object treats the arrows as a part of itself (even though the arrows are tagged differently), and so if an arrow hits another parented arrow they keep sticking together really stupidly in an ever growing row (middle cube).

Is there a way I can ignore the parented arrows when doing the raycast so that the new arrows are only parented to the object (blue cube) and not to the arrows already parented (right cube)?

Comment
Add comment · Show 4
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 ahaykal · May 24, 2013 at 12:48 PM 0
Share

I am not sure if I understood you correctly, but what I would suggest is to disable the collision of the arrows by layering them and then disable the physics between them.

So give the arrow a layer and then go to Edit -> Project Settings -> Physics and then uncheck the check mark of the layer.

avatar image robertbu · May 24, 2013 at 12:51 PM 0
Share

If you don't $$anonymous$$d them passing through each other, you could just turn off the collider on the arrow after parenting.

avatar image Hamesh81 · May 25, 2013 at 03:59 AM 0
Share

Ok, so basically the collision detection (the raycasting) of each arrow is only turned on when an arrow is actually being fired through the air. Once an arrow hits something it no longer checks for collision since the raycast is turned of. Also the arrows don't actually have colliders since the raycast does all the collision detection work.

I think the bulk of the problem comes from the fact that when an object becomes a child of something, the parent's tag in effect is transferred to the children, even if in the inspector the children have a different tag set manually. At least that is the way it is working for me. Both the cubes and the arrows have different tags, yet when the arrows become children of the cubes they behave as though their tag is the same as the cube. Yet when not parented if I fire an arrow towards a stationary arrow it will pass straight through it. Strange

avatar image robertbu · May 25, 2013 at 05:30 AM 1
Share

Your reported behavior (getting the tag from the parent ins$$anonymous$$d of the child) sounds strange. So I decided to test it. I could not reproduce the problem. I was able to parent the "arrows" to the wall, and when I shot the arrows, I was able to detect collisions with both the wall and the arrows. So something strange is going on here. It might be a bug in your code, or there might be something different in your setup from my setup.

I'd like you to try something:

  • Remove the parenting code from your arrow

  • Go to Edit/Project Settings/Time, and change your Fixed Timestep to 0.01 or even 0.005.

  • Select your arrow prefab and change the Collision Detection to 'Continuous Dynamic.

Then run and see what happens.

1 Reply

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

Answer by Hamesh81 · May 25, 2013 at 12:23 PM

Ah, I worked it out. There seems to be a difference between having the children "Untagged" and actually tagged differently from the parent. I thought that since the children weren't tagged they would be detected as different to the parent which had a tag set. When I set every arrow with an actual tag (different to the parent of course) the arrows aren't sticking together anymore.

So having the children simply untagged doesn't do it, because I suppose they assume the tag of the parent. They need be tagged but tagged differently. Thanks for your help robertbu

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 robertbu · May 25, 2013 at 03:53 PM 1
Share

I'm glad you got it worked out. Nice to know about untagged objects.

avatar image Hamesh81 · May 25, 2013 at 04:00 PM 0
Share

That's the first time I've got kudos for answering my own question!

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

14 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

Related Questions

Make a simple tree 1 Answer

How can I get the tag of a child object? 1 Answer

Access Parent NameTag? 1 Answer

GetComponentInChildren with tag in two variable 3 Answers

Get a raycast to hit only child objects to use axes 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