The goal of this book is to successfully create a shooter game, as stated earlier. In order to achieve this, we will start with the basics: making a simple first-person camera. We will facilitate the functions and math that LibGDX contains.
Since you have probably used LibGDX more than once, you will be familiar with the concepts of the camera in 2D. The way 3D works is more or less the same, except there is a z axis now for the depth. However, instead of an OrthographicCamera
class, a PerspectiveCamera
class is used to set up the 3D environment. Creating a 3D camera is just as easy as creating a 2D camera. The constructor of a PerspectiveCamera
class requires three arguments: the field of vision, camera width, and camera height. The camera width and height are known from 2D cameras, the field of vision is new.
The initialization of a PerspectiveCamera
class looks like this:
float FoV = 67; PerspectiveCamera camera = new PerspectiveCamera(FoV, Gdx.graphics.getWidth...