Game Development Reference
In-Depth Information
Attaching a weapon to our soldier
Attaching a weapon to our soldier is very easy with the Animation.AttachToBone
function. Given the correct offset values, we can position a sniper rifle grip into the soldi-
er's hand:
Sandbox.lua :
function Sandbox_Initialize(sandbox)
...
local weapon = Core.CreateMesh(
sandbox,
"models/futuristic_soldier/" ..
"soldier_weapon.mesh");
Animation.AttachToBone(
soldier,
"b_RightHand",
weapon,
Vector.new(0.04, 0.05, -0.01), -- position offset
Vector.new(98.0, 97.0, 0)); -- rotation offset in
angles
weapon = nil;
Running the sandbox now we'll see our soldier has a weapon attached to his right hand:
Search WWH ::




Custom Search