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 Jul 13, 2018 at 09:00 PM by BluesyPompanno for the following reason:

Problem has been fixed, by creating animations for each gun/weapon

avatar image
0
Question by BluesyPompanno · Jan 26, 2018 at 04:49 PM · characterbonehandlesinverse kinematichand

Character IK hand position and bone transform problem.

Hello.

I've had created and rigged a character in Blender.

My problem is I have a gun that is animated with reloading animation,aiming,walking,sprinting,idle ( animations created in Unity ) and character ( animated in Blender -> only legs are animated -> walking,idle,sprinting,crouching) and i want to make it so the character holds the gun with his hand and not the transform of his hand ( the bone transform)


Is there a way how to do this ? I had tried adding a bone on the hand and then positioning the hand on the green cube position. (hand didn't move) I had also tried changing the mesh of the hand ( didn't worked )

This is how he holds it.

alt text

and this is how i want him to hold the gun. alt text

I have gun with gameobjects that are supposed to tell which hand is supposed to be on that location. Blue cube - Left hand Green cube - Right hand ( Hand is positioned at its transform position )

Hands are controlled by IK.

This is my script.

  protected Animator animator;
 
     public bool ikActive = false;
     public Transform rightHandObj = null;
     public Transform lookObj = null;
 
 
     public Transform left = null;
 
   
     void Start()
     {
         animator = GetComponent<Animator>();
     }
 
 
     //a callback for calculating IK
     void OnAnimatorIK()
     {
         if (animator)
         {
 
             //if the IK is active, set the position and rotation directly to the goal. 
             if (ikActive)
             {
 
                
                 // Set the look target position, if one has been assigned
                 if (lookObj != null)
                 {
                     animator.SetLookAtWeight(1,1);
                     animator.SetLookAtPosition(lookObj.position);
                 }
 
                 // Set the right hand target position and rotation, if one has been assigned
                 if (rightHandObj != null)
                 {
                     animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
                     animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1);
                     animator.SetIKPosition(AvatarIKGoal.RightHand, rightHandObj.position);
                     animator.SetIKRotation(AvatarIKGoal.RightHand, rightHandObj.rotation);
                 }
 
                 if (left != null)
                 {
                     animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
                     animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1);
                     animator.SetIKPosition(AvatarIKGoal.LeftHand, left.position);
                     animator.SetIKRotation(AvatarIKGoal.LeftHand, left.rotation);
                 }
 
             }
 
             //if the IK is not active, set the position and rotation of the hand and head back to the original position
             else
             {
                 animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 0);
                 animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 0);
                 animator.SetLookAtWeight(0,0);
                 animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 0);
                 animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 0);
             }
         }
     }
 }


Anybody knows how to "fix" this ?

vystrizek2.png (110.1 kB)
vystrizek4.png (92.0 kB)
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 calpolican · Jan 26, 2018 at 08:58 PM 0
Share

Have you tried moving the I$$anonymous$$Goal of the hand? What's the I$$anonymous$$Goal parented to? I iguess it's parented to the gun handle. In game mode, position the I$$anonymous$$ goal well enough to have the hand in the desired position. Then copy the transform values of the goal. Exit play mode and paste those values in the same place from where you copied them. Unless I misunderstood what you're trying to do...

1 Reply

  • Sort: 
avatar image
1

Answer by theANMATOR2b · Jan 26, 2018 at 07:32 PM

The only issue is the position of the gun in relation to the hand? Im not a coder but I think there is something related to parent or child transform offset. That might help enough to point towards the correct code block.

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

103 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

Related Questions

Parent weapon to hand bone 2 Answers

How to play character animation after bone deparent? 2 Answers

Inverse Kinematics stopped working on character 0 Answers

Posing a Character? 1 Answer

What is the best way to let a character follow a moving object with his head 0 Answers


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