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 Aburkins · Jun 06, 2014 at 04:45 PM · charactercontrollerparent

Making the character controller a child of another object

I am developing an application for a CAVE-type VR setup that uses head tracking. I need to make the first-person character controller a child of the head tracker so that it follows head movements. I have been able to make this work with regular GameObjects, but not with the character controller. I figure there must be something special about it that keeps it grounded.

Any suggestions of how I can make the controller behave more like a normal GameObject, specifically being able to pair it to other objects?

My code for reference:

 public class AttachToHead : MonoBehaviour {
 
 public GameObject node;
 
  void Start () {
 }
  void Update (){
      if (MiddleVR.VRDeviceMgr != null){
          node = GameObject.Find("HeadNode");
          this.transform.parent = node.transform;
       }
  }
 
 }

I don't think you need to know anything about MiddleVR for this question. This code works as expected for GameObjects.

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

Answer by Stygtand · Jun 06, 2014 at 05:21 PM

Just to clarify, you want AttachToHead to be parent of node?

Try to debug. Can you even find the game object

 if (MiddleVR.VRDeviceMgr != null){
     Debug.Log(MiddleVR.VRDeviceMgr);
     node = GameObject.Find("HeadNode");
     Debug.Log(node);
     this.transform.parent = node.transform;
 }

if its not null, you found it and it will parent it.

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 Aburkins · Jun 06, 2014 at 06:07 PM 0
Share

Actually, it's the opposite. I want AttachToHead to be the child of node.

It finds the GameObject. I know this because I had this script attached to a cube, which made the cube the child of "HeadNode" (the head tracker). When I moved the tracker the cube moved as well. This is what I want it to do, only with a character controller.

avatar image Stygtand · Jun 06, 2014 at 06:46 PM 0
Share

Then do the other way around. http://docs.unity3d.com/ScriptReference/Transform-parent.html

 node.transform.parent = transform;

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

22 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

Related Questions

After unchilding a Character controller, it becomes disoriented 0 Answers

Make a simple tree 1 Answer

Making Rigidbodies the parent of character controllers is giving me problems. 1 Answer

Use Parent to fix the rotation of character 1 Answer

Character controller moves slow when an object its parented 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