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 /
This question was closed Apr 20, 2018 at 04:01 PM by Fibonacci_0_1_1 for the following reason:

solved the problem.

avatar image
0
Question by Fibonacci_0_1_1 · Apr 18, 2018 at 11:19 PM · transformhierarchyfindbonesbone

How do i find a bone on my character within a script?

Ive been trying to reference the "Head" bone on my character object but when i play the game it says "Cant Find HEAD" instead of "Found HEAD".

I've tried changing the path names and it doesn't seem to do anything, I've also tried changing the object of which the script is placed on but that hasn't changed anything either.

I've noticed that the bones are not shown in the hierarchy tab but they are shown only when i go into the configure option of inspector. does this have something to do with not finding the bone?

any help is greatly appreciated !

!!! ANSWER !!! Okay, I found out what was wrong. as @Priyanka-Rajwanshi explained, the above code would work only if the bone is shown within the hierarchy. Since I have "Optimize Game Objects" active on my player model's Rig, I had to add which bones I could control (add to the hierarchy) under "Extra Transforms to Control".

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class head_rotation : MonoBehaviour {
 
     private Transform head;
 
     
     void Start () 
     {
         
         head = transform.Find("Head");
         
         if (head)
         {
             Debug.Log("Found HEAD");
         }
         else
         {
             Debug.Log("Cant Find HEAD");
         }
     }
     
     
     void Update () 
     {
         
     }
 }
 





Comment
Add comment · Show 1
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 Fibonacci_0_1_1 · Apr 20, 2018 at 03:56 PM 0
Share

Okay, I found out what was wrong. the above code would work only if the bone is shown within the hierarchy. Since I have Optimize Game Objects active on my player model's Rig, I had to add which bones I could control under "Extra Transforms to Control".

2 Replies

  • Sort: 
avatar image
-1
Best Answer

Answer by Priyanka-Rajwanshi · Apr 19, 2018 at 04:15 AM

@Fibonacci_0_1_1 Try:

  player_head = transform.Find("Head");
Comment
Add comment · Show 5 · 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 Fibonacci_0_1_1 · Apr 19, 2018 at 05:13 AM 0
Share

nope didn't work. i dont know why its not working...

avatar image Priyanka-Rajwanshi Fibonacci_0_1_1 · Apr 19, 2018 at 05:45 AM 0
Share

Could you post a screenshot of the complete player hierarchy? Not the avatar configuration

avatar image Fibonacci_0_1_1 Priyanka-Rajwanshi · Apr 19, 2018 at 02:08 PM 0
Share

okay, i just did that. my hierarchy doesn't show bones it just shows the player_model and a child named body.

Show more comments
avatar image
-1

Answer by Cornelis-de-Jager · Apr 19, 2018 at 12:03 AM

simply try:

 player_head = GameObject.Find("Head");
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 Fibonacci_0_1_1 · Apr 19, 2018 at 05:12 AM 0
Share

i tried it, it didn't work.

avatar image MlleBun Fibonacci_0_1_1 · Feb 09, 2020 at 03:00 PM 0
Share

And player_head = GameObject.Find("Head").transform; ?

Follow this Question

Answers Answers and Comments

101 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 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 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 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 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

transform.Find always returns null 1 Answer

Free Move Bone On Rigged Object 0 Answers

How to get a recursive named bone transform? 3 Answers

Move armature bones in scene Hierarchy 1 Answer

Bone Not Rotating? 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