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
0
Question by Kith · Mar 25, 2010 at 03:02 AM · animationimportmaya

Swapping out parts of a model in code

Okay, I don't even know where to start with this one, so I have no code to present. But basically I want to be able to import a model (A guy with a gun), and be able to switch out the actual gun object with another object, and retain the animation. Basically the guns (modeled in Maya) would be similar in shape and proportion, but how would you do that in code? Is that possible?

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ZanzibarDreams · Mar 25, 2010 at 09:11 AM

Take a look at this question, maybe can help http://answers.unity3d.com/questions/6366/how-can-i-change-sword/6375#6375

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
avatar image
1

Answer by KvanteTore · Mar 25, 2010 at 07:30 AM

One way is to combine the meshes of the character with the mesh of the gun whenever the character chooses to change the weapon. At runtime you use the Mesh.CombineMeshes method to glue the meshes together.

Take a look at the character customization example, and specifically the CharacterGenerator script which puts the pieces together.

I am not really sure of the performance implications of this approach. Compared to having a separate GameObject for the weapon, it lowers the number of SkinnedMeshRenderers, which could improve performance. On the other hand, it might take a moment to actually combine the meshes.

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
avatar image
0

Answer by bowditch · Mar 25, 2010 at 03:05 AM

You should be able to split the animations up in the FBX importer in Unity without touching code for the import.

Create animations for both and then call them when you want the swaps. In the Animation Split feature in FBX Importer, make enter the start and stop keyframes for each set of animations.

Is that helpful, or am I misinterpreting what you are trying to accomplish?

Comment
Add comment · Show 1 · 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 Kith · Mar 25, 2010 at 03:20 AM 0
Share

I'm not trying to split the animations up. I know how to set up the "idle" animation frames, "walk" animation frames, etc. What I'm trying to accomplish is...Well let me put it this way lol. The end result is that I want to be able to pick up a new weapon, and when I do, have my player model hold that weapon, ins$$anonymous$$d of the weapon he was holding previously. What's the best way to achieve that?

avatar image
0

Answer by Dentvanboo · Nov 29, 2011 at 08:23 AM

Yeah I'm trying to do this exact thing as well. I have my character model, and a same character model with a gun, and when I run to a pickup with this gun I want the model without the gun to swap to a model with a gun... How easy does that sound? :D Any tips?

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

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

1 Person is following this question.

avatar image

Related Questions

Can I make animations snap to a frame? 1 Answer

Maya rigged object not importing correctly! 5 Answers

maya animation not importing correctly 0 Answers

no matter what i do i can't import an animation from maya 0 Answers

Maya to Unity Animation problems 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