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 /
  • Help Room /
avatar image
0
Question by megabrobro · Nov 26, 2017 at 12:02 AM · animationgameobjectarmature

Trouble referencing a bone. Even though animations working fine and Avatar imported skelton very satsifactorily

Hi all, I've been working away on a 3d game with an army guy running around shooting stuff.

I've got mocaps from the asset store that work with my model and he runs about fine now, but I have a gameObject called TriggerFingerPoint that I need to follow the trigger finger of the model , and then I have the GunTriggerPoint, which i want to attach to that bone.

Hope that makes sense... I couldnt find out how to do this with the unity docs im sad to say.

BTW: this is what i tried so far, but it seems like it thinks "hand_r" doesnt exist because that line throws a null exception

  private void Start()
     {
         rb = GetComponent<Rigidbody>();
         playerAnims = GetComponentInChildren<PlayerAnimations>();
         absoluteGround = rb.transform.position.y;
         distToGround = GetComponent<Collider>().bounds.extents.y;
         gunTriggerPoint = GameObject.FindGameObjectWithTag("GunTriggerPoint");
 
 
         gunTriggerPoint.transform.SetParent(GameObject.Find("hand_r").transform); 
         gunTriggerPoint.transform.position = new Vector3(0, 0, 0); 
         gunTriggerPoint.transform.rotation = Quaternion.identity; 
     }


I've also now tried this and the null exception has gone, but if I try to something like (gunTriggerPoint.transform.position = handR.position; (I also tried handR.transform.position), then I get null reference error.

new code:

     Transform handR;
 
     private void Start()
     {
         rb = GetComponent<Rigidbody>();
         playerAnims = GetComponentInChildren<PlayerAnimations>();
         absoluteGround = rb.transform.position.y;
         distToGround = GetComponent<Collider>().bounds.extents.y;
         gunTriggerPoint = GameObject.FindGameObjectWithTag("GunTriggerPoint");
         handR = transform.Find("hand_r");
 
         gunTriggerPoint.transform.SetParent(handR);
         gunTriggerPoint.transform.position = new Vector3(0, 0, 0);
         gunTriggerPoint.transform.rotation = Quaternion.identity; 
     }


Also, the gun even though now parented doesnt follow the player, and rather floats in mid air doing nothing

Further note: The gun has no parent. I checked in the heirarchy. I also tried just instantiating a new gun and setting parent, it made no difference

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 megabrobro · Nov 26, 2017 at 12:46 AM 0
Share

Also, the gun even though now parented doesnt follow the player, and rather floats in mid air doing nothing

0 Replies

· Add your reply
  • Sort: 

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

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

Doomed animation (Inverse kinematics) 0 Answers

Rigged non-human mesh animating sideways even AFTER rotation correction in Blender 0 Answers

Problem with game animation for gameobject movement 0 Answers

Child to parent behave weird 0 Answers

Head and body as seperate mesh with animations 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