Skrakle Posted March 7, 2015 Share Posted March 7, 2015 I'm trying to add a weapon at a specific bone on my character but finding the child using bone name returns nil. I've also tried several other names in the hierarchy. local child=self.entity:FindChild("dwarfmale_stand_bone_RFingerPinky"); Quote Link to comment Share on other sites More sharing options...
CreativeOcclusion Posted March 7, 2015 Share Posted March 7, 2015 you may try watching this video about weapons....may help, may not.... Quote Link to comment Share on other sites More sharing options...
Skrakle Posted March 7, 2015 Author Share Posted March 7, 2015 Thanks for the video link but it didn't help because i really need to attach it to a specific bone so my sword will follow/rotate correctly when my character walks or takes a swing and i haven't seen anything bone related in the tutorial. I forgot to mention that i'm loading my models in lua instead of placing it in the editor. I did place one so i can find the bone names. Quote Link to comment Share on other sites More sharing options...
macklebee Posted March 7, 2015 Share Posted March 7, 2015 We would probably need to see your code/model as I just renamed the hand bone on my model to 'dwarfmale_stand_bone_RFingerPinky" and was able to find it and parent a weapon to it with no issues. I suspect maybe a typo somewhere or since maybe 'child' is a local variable, you are trying to access it out of scope? Edit -- and fyi, it appears you have to match capitalization... so make sure the string matches exactly as shown for the bone name. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Skrakle Posted March 7, 2015 Author Share Posted March 7, 2015 I copy/pasted the bone name from the editor. Dwarf model: Dwarf fbx Weapon Weapon entity={}; function App:Start() entity[0]=LoadModel("Models/Characters/Dwarf/dwarfmale_run.mdl","Char","Randgard",0,0,5.73,0.02,1,Collision.Trigger,Entity.CharacterPhysics,""); entity[0]:SetScript("Scripts/NPCS/player_character.lua"); weapons[0]=LoadModel("Weapons/axe_1h_hatchet_a_01.mdl","Weapon","Axe",0,0,0,0.02,0,Collision.None,Entity.RigidBodyPhysics,""); local child=entity[0]:FindChild("dwarfmale_stand_bone_RFingerPinky"); if (child) then weapons[0]:SetParent(child); weapons[0]:SetMatrix(entity[0]:GetMatrix()) end end Quote Link to comment Share on other sites More sharing options...
macklebee Posted March 7, 2015 Share Posted March 7, 2015 hmmm i think there is a mixup somewhere... you are loading the 'dwarfmale_run' model but you are trying to find the 'dwarfmale_stand_bone'. In the model you posted there are no 'stand_bones' - only 'run_bones'. I am able to find the 'run_bone' no problem... I think you are just loading the wrong version of the dwarf in the editor to find the bone you want, but then are loading a different dwarf model via code that doesn't have that naming convention - therefore its not finding the bone... 2 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Skrakle Posted March 7, 2015 Author Share Posted March 7, 2015 hmmm i think there is a mixup somewhere... you are loading the 'dwarfmale_run' model but you are trying to find the 'dwarfmale_stand_bone'. In the model you posted there are no 'stand_bones' - only 'run_bones'. I am able to find the 'run_bone' no problem... You're absolutely right, I can't believe i didn't notice that! Thanks for noticing! 2 Quote Link to comment Share on other sites More sharing options...
YouGroove Posted May 15, 2015 Share Posted May 15, 2015 My sowrd is too big and needs a rotation. How to change that in the code ? self.sword = Model:Load("Models/sword.mdl") local child=self.entity:FindChild("Bone_002_R_002"); if (child) then self.sword:SetParent(child); self.sword:SetMatrix(self.entity:GetMatrix()) end Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted May 15, 2015 Share Posted May 15, 2015 Got it working without using matrix. self.sword = Model:Load("Models/sword.mdl") local child=self.entity:FindChild("Bone_002_R_002"); if (child) then self.sword:SetParent(child); local pos = child:GetPosition(true) pos.z = pos.z + 1 pos.x = pos.x - 0.5 self.sword:SetPosition(pos,true); local rot = child:GetRotation(true) self.sword:SetRotation(rot,true); end 2 Quote Stop toying and make games Link to comment Share on other sites More sharing options...
martyj Posted May 19, 2015 Share Posted May 19, 2015 Where did you get your dwarf model btw? Quote Link to comment Share on other sites More sharing options...
Skrakle Posted May 19, 2015 Author Share Posted May 19, 2015 Where did you get your dwarf model btw? It's a model from WoW that i extracted using a tool, it's used for testing only. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.