Tutorial: Functional Binoculars for the Blender Game Engine

Introduction This tutorial explains how to make fully-functional simulated "binoculars" for use in the Blender Game Engine. This technique is especially useful for FPSes and other games with a first-person perspective. It assumes some familiarity with Blender's controls and usage, but is detailed enough that anyone should be able to follow the directions without difficulty.

The first step is to add another camera which has the same origin point as the camera you already have.  Parent the new camera to the original camera (Ctrl+P).  (This will ensure that the binoculars can be controlled using the same controls as the original camera.)  Now set the camera's Lens value (which can be found in the Edit buttons,  or F9) to a high value.  I used 150.  Also make a note of the new camera's Object name,  pointed out in the illustration with a red arrow.  You'll need this later.
Set up the following array of Logic Bricks on the new camera:

Also add a Boolean (Bool) property called binoculars and set it to False.

I'll go through this setup a piece at a time to help you understand it.  The Property binoculars is a Boolean property which the game engine will use to track whether you're looking through the binoculars or not.  Be sure the property is set to Bool or it will not work correctly.  The first logic set is fairly simple:  when the "B" key is pressed -> (AND) -> Assign the property "binoculars" the value !binoculars.  This looks odd at first,  but it's really just the way to tell the game engine to set a Bool property to its opposite. (True becomes False and vice versa).

Further on the logic bricks tell the game engine what to do depending on the state of the Bool property.  If it's True,  the game engine switches the view to our new camera (this is why you needed to save its name) and adds the OverlayScene called Binoculars.  (We will make this scene in the next step)

If the property is False,  the GE does the opposite,  switching back to your usual camera and removing the Binoculars scene.

Note that Blender does not allow you to reference scenes which do not exist yet in the logic bricks.  You'll have to add actuators relating to the Binoculars scene after you create it in the next step.

The last step... making an overlay so that your binoculars have that cheesy double circle they always use in the movies!

Add a new empty scene and name it Binoculars. (At this point you can finish the actuators from before) In the empty scene, add a camera with a plane in front of it, as seen at right. >

In GIMP or Photoshop make an Alpha-masked texture for the double-circle. (You can alternatively just use the one from my demo file.) Set the face to Alpha drawmode while in Face Select mode, and you're ready for action! Go back to your original scene, and you should now be able to use the binoculars by pressing B.


Challenge For an additional challenge, try creating a function which allows the player to zoom in and out. Hint: the solution involves a Lens IPO and the IPO/Property actuator. Good luck!