O'Reilly logo

WebGL Game Development by Sumeet Arora

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

Simple bullet action – linear animation

In this section, we will add another object to our scene, the bullet (Bullet.json), and we will move our bullet in a straight line, unlike Angelina Jolie's movie Wanted, where the guys curve bullets. We can do that by applying B-spline interpolation but we are still medieval and we will save it for our grenade.

The equation to move the bullet is simple: f(x)=z. We will simply change the z value to move the bullet. However, this is awful because if we rotate ourselves (the camera and subsequently, our arm), the bullet should go in the arm's direction. To achieve this, we need to apply the camera transformation to the bullet. Each bullet will have the same defined set of points, let's say (0,0,1),(0,0,2)...(0,0,200), ...

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