Seeing through walls

A neat feature of many titles is being able to see enemies or important objects through walls, similar to the detective mode in Batman: Arkham Knight, the thermal vision in Splinter Cell, or the outlines in Evolve and other games. Let's implement similar functionality now.

Getting ready

Before we start working within the Unreal Editor we will need to have a project to work with:

  1. First, open up the Unreal Editor by clicking on the Launch button from the Unreal Engine Launcher.
  2. Start a new project from the Project Browser tab by selecting the New Project tab. Select First person and make sure that With Starter Content is selected. Give the project a Name (Cookbook_Chapter7). Once you are done, click on Create Project.
  3. You should see a level similar to this:
    Getting ready

How to do it…

In order to see other objects, let's first add an object that we'd like to see into the level:

  1. Open up the Example_Map file and from the Content Browser tab, go into the Character folder and drag a HeroTPP skeletal mesh into the level. This will be our enemy that we will want to see no matter where they will be.
    How to do it…

    Adding the enemy

  2. Let's now create a new material that we can work with and give it a name (SeeThruMaterial). Once it's created, open up the Material Editor.
  3. First, create Constant3Vector with a color of your choice and assign it to the Emissive Color property.
  4. After this, deselect it so that nothing is selected and go to the Details tab. From here, change the Blend Mode to Translucent.

    This blending mode is used for objects that require some form of translucency and is applied onto areas in front of it, but this mode also has another feature that is perfect for what we want to do. We will look into it next.

    Note

    For more information on how to use Transparency effectively, refer to https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/HowTo/Transparency/index.html.

  5. Go into the Translucency section and toggle the Disable Depth Bias property to be enabled. This will say that we should draw this on the top of the screen even if we're behind something else.
    How to do it…

    Setting the translucence value

  6. Once you're done, hit the Apply button and then close the editor. Then, apply the newly created material to the enemy and move around the camera to see the effect that we generated!
    How to do it…

    Applying translucence to the enemy

  7. To see it in action in the game, go to the toolbar and hit the Play button to start the project!
    How to do it…

With this, we can see the object no matter what! Later on, you can use this recipe with the knowledge of blueprints to toggle the effect.

Note

Tom Looman also came up with another implementation using the Render Custom Depth flag that looks similar to the game Evolve with outlines. It can be found at http://www.tomlooman.com/ue4-evolves-outline-post-effect/.

See also

Now, there is much more that exists in the Material editor, especially when you add more complex interactions and/or apply them to meshes to create some interesting effects. Here are some additional tutorials that may be useful to you going further:

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

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