O'Reilly logo

Learning Game AI Programming with Lua by David Young

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required