Getting our soldier to shoot
Before we use the Soldier_Shoot
helper function provided by the sandbox, we should implement our soldier shooting by hand. Overall, the process of shooting a bullet requires a look up of the bone position and rotation for the soldier, creating a physics representation for the bullet, attaching a particle system to the bullet, launching the profile, and then handling the impact of a bullet with any other physics simulated object.
The bone position
Getting a bone position requires passing a sandbox object or mesh to the Animation.GetBonePosition
function. GetBonePosition
also works for any attached object that contains bones as well. This allows you to retrieve the bone position of a bone within the weapon while it is attached to the soldier, for example:
local position = Animation.GetBonePosition(sandboxObject, boneName);
The bone rotation
Bone rotation is exactly the same as getting the bone's position, except that it returns a vector that represents the...