Animating a zoomed view

A core element of modern first-person shooters is a variable FOV in the form of a player's ability to look down the scope of a gun to get a closer view of a target. This is a significant contributor to the feeling of accuracy and control that modern shooters provide. Let's add a simple form of this functionality to our prototype.

In an empty section of the grid next to your Mouse input nodes, right-click, search for zoom, and add an InputAction Zoom trigger node. We want to modify the FOV value that is contained within the First Person Camera Component, so we go to the Components panel and drag First Person Camera out onto Event Graph.

Drag the output pin into empty grid space, search for the Set Field Of View node, and place it. Lowering the FOV gives the effect of zooming into a narrower area in the center of the screen. Since the Default FOV value is set to 90, for our zoom, let's set the FOV in the set node to 45, like this:

Click and drag the output execution pin from the right-click trigger node to the input execution pin of the set node. Compile, save, and click on Play. You will notice that when you are playing the game and press the right mouse button, the FOV will snap to a narrow, zoomed-in view. Any instance where the main camera snaps from one position to another can be jarring for a player, so we will have to modify this behavior further. Also, the FOV does not reverse when the key is released. We will solve both problems using a timeline.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset