Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 KuPAfoo · Nov 28, 2013 at 07:05 PM · prefabblenderarmatureequipment

Equipping unity prefabs to blender armature

Okay... so, I've refined the question below to a better, more specific question: http://answers.unity3d.com/questions/572821/equipping-weapons-to-photon-prefabs.html

My new question is about making a child snap-to influence on runtime.

I'm creating a Photon based RPG. In this RPG there are many elements I must focus on at this point of creation:

->All player models should be able to access all the same weapons and shields ->Weapons can be sheathed ->Players can run/walk with a weapon wielded

So, here's the obstacles; ->Player model must have a sheath bone ->Weapon must be able to become a child of both the hand.R bone and the sheath bone, switchable on runtime ->Sheild must be able to become a child of both the hand.L bone and sheath bone

The questions are mainly about blender structure, and unity parenting.

Should I have a weapon bone at all times so a weapon could be used in ANY animation?

Should I have a shield bone?

how do these retain location/rotation? the shield and sword inherits rotation and position of the bone? How do I determine "influence" as labeled in blender within unity? Influence makes the weapon closer or farther from the bone parented from.

I also believe that just as the player, I should put each weapon model inside of a prefab in unity. This way I can create/destroy weapons when equipped?

a sequence of events just to make sure I'm understood: player.Spawn(); weapon.Spawn.state=sheathed(childOf(sheathBone)); player.Weild(); weapon.state(childOf(Hand.R));
player.Animate(walk);

this is just a pseudo code, and wouldn't work. I'm just making sure the logic is correct before I jump into animating the player.

I can add some blender screenshots later.

EDIT: Thanks to AlejandroGorgal I've gotten the following result: alt text

Using Pre-defined place holders from the blender file, I was able to actually child the imported models to the fixed models and render them with no material.

The Sheath is a empty game object, but the animSword is a no material blender object. For animating the equipment it just seemed more logical the equipped weapons inherit the animated weapons' properties?

Is this a decent method? alt text

equiptest0.jpg (27.6 kB)
11-30pun.jpg (89.8 kB)
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
1
Best Answer

Answer by AlejandroGorgal · Nov 28, 2013 at 07:38 PM

Your best option is not to create a specific weapon bone in Blender but to create an empty object in Unity and attach it to the character's hand bone in the editor. All weapons you add here (provided that they are centered) will be added to the same location, so if they are not fitting exactly the player's hand you can simply move the emptyObject until they are on the location you want.

In Blender make sure that all weapons have their grip on the same location, this way when you add them to the empty object they'll all fit the player's hand perfectly.

Load up all your weapons to this new empty Object and add your weapon switching script there.

Comment
Add comment · Show 12 · 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 AlejandroGorgal · Nov 28, 2013 at 09:15 PM 1
Share

If you want it to swap location (like say going from the player's hand to his back) then you will need to add two game objects, each with the same weapons on it and enable one and disable the other depending on whether the weapon is equipped or not.

avatar image AlejandroGorgal · Nov 30, 2013 at 03:35 AM 1
Share

To create an empty object go to the menu at the top: Game Object > Create Empty.

Then on the Hierarchy pane select your character and expand it, you should see the list of bones it has, keep expanding it until you find the hands, then drag and drop your new empty object there.

This video tutorial should explain the logic of how this works: http://www.youtube.com/watch?v=OXo5AYPnL1c

avatar image AlejandroGorgal · Nov 30, 2013 at 09:38 PM 1
Share

You will have to try to be sure but Im almost 100% sure that it will retain to changes.

Try this: drag the prefab to the Hierarchy pane, make your changes then select the top (the parent) of that prefab on that same hierarchy view list, on the inspector you'll see a button that says Apply, whenever you press this whatever changes you've made here will be applied to the original prefab you have on the assets folder.

In my experience doing this saves all of the changes, the only thing it doesn't seems to save is when you target other separate gameObjects (such as enemies) but that shouldn't be a problem for you since you are doing a different thing.

Hope that helps.

avatar image AlejandroGorgal · Dec 01, 2013 at 01:41 AM 1
Share

I think your changes are the same, I really didn't know about meshes without materials in Blender as I usually used an empty object for that, but as long as it allows you to attach a weapon mesh to it then it's fine.

Now, for enabling and disabling the weapons the best method is probably to simply turn off the mesh rendered, like so:

 renderer.enabled = false;

This code needs to be on the weapon itself, so Im thinking (I haven't actually done this just yer) that on the weapon you could have a script that's something like this:

 var weaponState: boolean = false;  // weapon will be disabled by default
 
 function Update()
 {
 if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space) && weaponState == false)
 { 
 renderer.enabled = true;
 }
 else if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space) && weaponState == true)
 { 
 renderer.enabled = false;
 }
 }

This code is untested, but in theory when you press the spacebar key it should toggle the mesh rendering on and off.

avatar image AlejandroGorgal · Dec 01, 2013 at 01:55 AM 1
Share

Apologies, the idea itself was ok but my code had some errors, here's a working version:

 var weaponState: boolean = true;  // weapon will be disabled by default
 
 function Update()
 {
 if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.LeftShift) && weaponState == false)
 { 
 renderer.enabled = true;
 weaponState = true;
 }
 else if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.LeftShift) && weaponState == true)
 { 
 renderer.enabled = false;
 weaponState = false;
 }
 }

This was actually a very useful test as I plan to use this same system myself :)

Show more comments

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

17 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

Related Questions

Control Rotation Upon Animation Play 0 Answers

A question about unity prefabs and their animations.. 0 Answers

Different Armatures Performing Different Animations 1 Answer

Animations from Blender jerky/skipping frames 1 Answer

Blender Animation ? 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