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 /
avatar image
2
Question by Jason Mathews · Mar 14, 2010 at 02:58 PM · characterweaponbone

Equiping Weapon to a Character

So I'm animating my character in max and importing to unity. Now I'd like to be able to switch weapons within the code in game and was wondering how I'd go about doing it so that the weapon moves with the animations.

Thoughts.. 1. Attach the weapon to a bone in the skeleton from max. This is a bone just for one handed weapon angles and movements. But this would need the weapon to be part of that bone 100% within unity not sure if I can do that.

  1. Add the weapon to max and have different animations for each type. (yuck)

Help would be appreciated, I'm not a programmer and this is all very new to me. I think I've been doing pretty well though.

Thanks.

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

Answer by duck · Mar 14, 2010 at 08:18 PM

In Unity, all bones are just Transforms, so you can attach child objects to any particular bone just as easily as parenting an object to a normal gameObject. This can be done in the editor, or via scripting.

For more information in general about using animated characters in Unity, read this manual page:

Unity - Character Animation

To parent an object to another at runtime using script, it's simply a matter of assigning the transform.parent property to some other object's transform. In your case you'd want to set the weapon object's transform.parent to the hand bone's transform.

You might also want to subsequently set the weapon's localPosition and localRotation to Vector3.zero and Quaternion.identity respectively (depending on how your weapon's pivots are set up).

Comment
Add comment · Show 3 · 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 Jason Mathews · Mar 14, 2010 at 08:49 PM 0
Share

Awesome! Thanks this helps a lot.

avatar image Orion 1 · Mar 26, 2010 at 02:00 PM 0
Share

I'm having trouble with this. Once I parent my weapon to the hand bone, the bones seem to "disconnect" from the body and don't get animated anymore (while the deformed mesh does!).

avatar image Jason Mathews · Mar 31, 2010 at 03:22 AM 0
Share

I haven't tested fully YET, but I'm adding a specific bone in 3ds $$anonymous$$ax to represent the sword/gun/bow/etc. This way it doesn't affect the rest of the bones or weighting.

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

No one has followed this question yet.

Related Questions

Realistic weapon movement with the character 0 Answers

Is there a limit to the number of bones in a model 2 Answers

Switching weapons animation with mecanim? 2 Answers

Animation system 1 Answer

How to change add weapon charater on a starter kit 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