Jump to content

How to make a character hold a weapon?


suicaokhoailang
 Share

Recommended Posts

I have two seperate models in Blender: a guy and a sword. I don't need anything too complicated, just something like attaching the sword to the guy's hand. I tried creating a bone for the sword, made it the hand bone's child so it could animate alongside with the hand, then joined the two meshes together. Now I can export the model just fine, but when I try adding a simple animation, the exporter throws some weird errors. I think I did something wrong, what is the right way to do this task?

 

	Exporter version: 4.4.3, Blender version: 2.77 (sub 0)
========= Conversion from Blender to Babylon.js =========
	Scene settings used:
		selected layers only:  false
		flat shading entire scene:  false
		inline textures:  false
		texture directory:  C:\Users\Khôi\Desktop\
	Python World class constructor completed
	WARNING: The following armature not visible in scene thus ignored: Armature
	processing begun of mesh:  sword
		animation processing begun
		processing begun of baked material:  sword
========= An error was encountered =========
  File "C:\Users\Khôi\AppData\Roaming\Blender Foundation\Blender\2.77\scripts\addons\io_export_babylon.py", line 329, in execute
    mesh = Mesh(object, scene, nextStartFace, forcedParent, nameID, self)
  File "C:\Users\Khôi\AppData\Roaming\Blender Foundation\Blender\2.77\scripts\addons\io_export_babylon.py", line 785, in __init__
    bakedMat = BakedMaterial(exporter, object, recipe)
  File "C:\Users\Khôi\AppData\Roaming\Blender Foundation\Blender\2.77\scripts\addons\io_export_babylon.py", line 2090, in __init__
    bpy.ops.object.select_all(action='DESELECT')
  File "C:\Program Files\Blender Foundation\Blender\2.77\scripts\modules\bpy\ops.py", line 189, in __call__
    ret = op_call(self.idname_py(), None, kw)
ERROR:  Operator bpy.ops.object.select_all.poll() failed, context is incorrect
========= end of processing =========
elapsed time:  0 min, 0.006 secs

 

Link to comment
Share on other sites

On 11/03/2016 at 11:31 PM, Dad72 said:

Yes: 

sword.attachToBone(skeleton.bones[34], character);

I made a small bone search function by name, which can help.

var searchBoneByName = function(skeleton, searchBoneName) {
    var index = ;
    for (var i = ; i < skeleton.bones.length; i++)
    {
    	if (searchBoneName = skeleton.bones.name) {
    		index =  i;		
    		break;
    	}		
    }
    return index;
};


sword.attachToBone(skeleton.bones[searchBoneByName(skeleton, "main_gauche")], character);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...