Jump to content

LE3 : Tutorial make attachable weapon from Blender


YouGroove
 Share

Recommended Posts

For Blender users :

After a good bucnh of rotation trials on weapon export to FBX i found the good way to export it, so i share it for interested people.

 

You need to make some bone special to handle the wapon on the hand like on the picture.

Next the weapon must be aligned differently from axis compared to the model like on the picture also.

 

By keeping that convention you will be able to place weapons or other stuff using only the SetMatrix() function directly (without offsets or rotation tweakings)

 

The code in Lua is :

 


Script.LeftHand = "Bone.003_L.004"--string

--self.weapon = Model:Load("Models/other/weaponV5.mdl")
Script.weap = Model:Load("Models/ff7.mdl")
Script.weap:SetPosition(0,-100,0)

 

 


function Script:UpdatePhysics()
...
local child = self.entity:FindChild(self.LeftHand)
mat = child:GetMatrix();
self.weap:SetMatrix(mat)

 

attachweapon.jpg

 

 

Here is some ingame screenshot (it's not perfect caus weapon was placed approximatively , like the size, caus it's too big, and like the bone for weapon that was quickly made without taking care of good placement and rotation)

 

attachingame.jpg

Stop toying and make games

Link to comment
Share on other sites

I think it's better for perfomance to find the bone once and then store it in some variable. Not to look for it every update.

 


local child = self.entity:FindChild(self.LeftHand)

 

function Script:UpdatePhysics()

...

mat = child:GetMatrix();

self.weap:SetMatrix(mat)

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.

 Share

×
×
  • Create New...