Simple Zoom In/Out

This is a basic Unreal Engine 4 guide on how to zoom in when you hold the button and zoom out when you release the button. This is useful when making binoculars or telescopes that the player can see through. Includes adding post process effects after zooming in and resetting it after zooming out. You can add this feature to any first person or third person project.

  1. Make sure you have a new Action Mapping set up in the Inputs tab of Project Settings. If you don’t, add a new Action Mapping. Choose any key you want and name the action Zoom. I chose right click for zooming in/out.
  2. Go to the character blueprint. If you are using the Third Person Template, it should be called ThirdPersonCharacter.
  3. Create two new variables. The type of both variables should be PostProcessSettings. Name one of them NormalPP and the other ZoomPP. Set the NormalPP to your character’s camera’s post process settings if you changed the camera’s post process settings. You could also set NormalPP to your character’s camera’s post process settings in a BeginPlay node. Basically, NormalPP has to be the same as your character’s camera’s post process settings, or else everything will look off once you’ve zoomed in and out.
  4. Under the Scene Color tab in ZoomPP‘s default settings, change Fringe Intensity to around 1 to 2. This will simulate an artifact in cameras that causes things close to the edge of your screen to change colors. The higher the value, the more intense it is. Also make Vignette Intensity somewhere between 0.7 and 1. Vignette makes the corners of your screen darkened, and the higher the number, the more prominent the effect. If you want your telescope or binoculars to appear to be old, you can change the Scene Color Tint to yellowish brown so the lens appears to be dusty.zoominandout
  5. With the post process settings done, you can add the Zoom InputAction node to the character blueprint. Connect Pressed to a Set Field of View node for your camera. Your camera should be called Follow Camera if you are using the Third Person Template. Duplicate that node and connect the new node to Released. The pressed field of view should be a smaller value, like 30 or 40 or 50. The smaller, the more zoomed in the view will be. The released field of view is your camera’s current field of view, which defaults to 90. I set my default fov to 100.
  6. After that, set the post process settings of the camera to ZoomPP for Pressed, and NormalPP for Released.
  7. Done! Press and hold the zoom key and you will zoom in. Release it and you will zoom out. Example:zoomin

I hope this was helpful to you!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s