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 WillyJenkins · May 27, 2013 at 01:28 PM · cameracolliderphotonthird person controller

Get the collider component of a child element

I've been looking at this for a while now but haven't managed to get it working.

I am using the Photon Networking Engine to build an online game, at the moment when a user starts the game, it joins either the available room or creates a new one. This then instantiates a new instance of my character prefab. The character has a third person camera control script which initially used the characters capsule collider as a point to follow and zoom to. I have removed the capsule collider and added colliders to each child of the object to create a more accurate collider.

Now what I need to do is get the collider of the "Head" child of my character and set it as the target in the camera control script, also later I will introduce a 1st person camera control and will need to keep the position of the camera inside the "Head" child's position. How would I go about getting the collider component of my character object's child.

For reference the Head child is at vincent (the character object) > Hips > Spine > Spine1 > Spine2 > Neck > Neck1 > Head. I don't know if this makes a difference to the way it is done. Could I just give my Head child a tag or layer and get the collider component that way?

Thanks in advance.

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
0
Best Answer

Answer by Graham-Dunnett · May 27, 2013 at 01:34 PM

The hierarchy in Unity is through Transform components. All GameObjects have Transforms. So, see:

http://answers.unity3d.com/questions/10417/how-can-i-access-the-children-of-a-transform.html

to figure out how to traverse your hierarchy, then use GetComponent.

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 WillyJenkins · May 27, 2013 at 02:07 PM 0
Share

That looks perfect thanks. I assume I iterator through every child, then check to see if it is the "Head" child, if so use 'GetComponent();'. Would this be found using child.name?

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

Very complicated collider problems 0 Answers

ThirdPersonController character hovers above capsule collider 2 Answers

Problem with gravity in a Third Person Controller 0 Answers

Internal collisions 1 Answer

How to change first person controller input when passing through a collider? 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