Diablo Style Wall Hiding in Blueprints.

Hey all! I made this a couple weekends back as part of a pet project I’m working on, figured I’d share with the class. I wanted to emulate the wall hiding feature in Diablo in my game, where the geometry that blocks you from the camera fades away as you move behind it, and fades back in as you move in front of it. Note: There are many ways to accomplish this task, but this is how I went about it :slight_smile: (Forgive the non-uniform screen grabs, its late)

To approach this problem, I broke it down into the two parts that would be interacting - The Player and The Wall.

I knew I needed to know when my player went behind or came out from behind the wall. These two Events needed to trigger two Actions - Hide and Show.

The Player causes the events, the wall receives the calls to action.

The Wall - Hideable_Actor

Since I wanted to fade in and out over time, I knew I needed to handle the fade using the Tick function’s delta, and a Material instance of a material with a scalar parameter into it’s Opacity channel. See 3 pictures down that I set this up as a dynamic material instance as well, and cached it to a class variable on the EventBeginPlay.



Fading over time meant I’d have to do some internal state control on the Hideable_Actor, and I handled this with two booleans - **ShouldHide **and ShouldShow. Using these two variables, The blueprint could decide whether or not it should UpdateVisibility, another function I added to control the fade at each frame via Tick. If either of these was true, the fade would happen in the appropriate manner. I even added a fadespeed so I could make the fade in/out faster by multiplying it by the Tick’s delta.


Inside the UpdateVisibility function, I set the opacity parameter on my dynamic instance by a little more, up or down based on which boolean was true. I used some logic to clamp and reset the ShouldHide and ShouldShow booleans in order to stop the function from being fired once the desired opacity was achieved.


I built the wall to have two public functions to handle these actions - **Hide **and Show - that could be called by an outside force. These basically just toggle the booleans for ShouldHide and ShouldShow.



And that’s it for the Wall.

The Player

I build this originally from a modified version of the topdown content example. Basically, I re-positioned the camera to something a bit more what I was looking for, and added a long, scaled Box, used as a trigger in between the camera and the player mesh. This box will be what we use to test if the player is going behind the wall.


With the box selected, I added our events, choosing **OnComponentDidBeginOverlap **and OnComponentDidEndOverlap. In these events, I cast the OtherActor from the Event to our Hideable_Actor, and do the appropriate function based on going behind or coming back out. When the box overlaps with the Hideable_Actor, we want to hide. When it’s no longer overlapping, we want to show.


And here is the result!





And again in horrible, phone recorded glory from my vine :slight_smile:


Thanks for playing! :rolleyes:

I was literally looking at Project Zomboid earlier today and wondering how I would handle wall hiding myself. Thanks for the timely guide on this method. :slight_smile:

Thanks for posting this. I’ll have to look into adding this to some projects.

Sure thing! and you should be able to subclass the Hideable_Actor so you can make many different Blueprint assets with it :slight_smile: I’ll try to get the BP uploaded at some time, too

Here’s the uasset, too. - Download

If you use this as a base blueprint class, Set the mesh, fade rate, and name of your Scalar Parameter from your Material Instance inside defaults.

Hideable_Actor Settings.PNG

I did something similar to this but my wall don’t fade the just disappear when my player goes behind it.


This Mesh good for all, like hiding object from UE4 mesh and import object from (Ex: 3Ds Max, Maya, Modo and Etc.)


nice solution. If i see it correctly, you need 2 Meshes per entity? One for the base and one for the hideable one?
If that’s the case, why not using a normal mesh with a clipplane to cut the mesh at a given height? By drawing the backfaces in a solid color it’s possible to fill the hole.


Didn’t read that one at first my bad^^"

Thanks! This is really great. I’d been trying to solve the fade in/out a PSR blueprint I’d built for general interaction. I kept trying to go about it was a Material Param. Modification, but this works much better.

What would be the performance difference or preference between doing a trace from the camera to the player vs setting up a box like you a have done to detect walls?

Hello ! Really great tutorial !

I have just a little problem with it, it’s working, but when the object disapears, there is no fadeout on it, and when it supposed ti show again, nothing happen…

I should probably update this now that it’s nearing a year old, heh :slight_smile: I’ll see what I can do to better break it down and update for 4.7 / 4.8

Im not entirely sure what the difference would be, but I can’t imagine that a continual trace check is more performant. I prefer the box because it’s very easy to quickly adjust the size for testing until it feels just right. Just be sure to appropriately set up the collision channels :slight_smile:

Hey Chance thanks for the tutorial. I was intending to do something similar but I am cautious of performance hits on translucent materials as well as their reflection limitations.

My theoretical workaround is one of these two:

a) Have an opaque and a translucent material for each hideable object (realistically that’d be two different master materials) and change the object’s material as it hides / shows.

b) Use one material but change it to opaque / translucent as needed.

I am not sure if b is even doable at runtime (I know you can override the opacity mode in instances) and if it is, which one (if any) is performance friendly?

I will have to use the same technique to say, fade out the player when he teleports.

Hey Chance,
You should totally make it network friendly so it only turns invisible to the player 0 :wink:

I “could” but I’m not building a multiplayer game :slight_smile:

I wonder if a similar technique would work in 2.5D with a perspective camera to achieve something similar to this:

A circle of transparency.

C’mawn Chance, I know you really want to :wink:

I actually tried but am getting some weird and inconsistent behaviors with it …

I’ll see if I can carve out some time to handle it. It’s kind of a weekend project that’s taken the backseat of another vehicle (not sure who’s driving anymore).

Jokes aside, I’ll let you know if I can get it implemented. I made a ton of changes to this when I upgraded to 4.6, so it’d be a full refactor at this point.


Fading scenery

Hey all, I know this is an old thread but I ended up needing to create something similar and wanted to make a quick tutorial for 4.7. I ended up trying to use a custom Actor Component so I could just add it to each static mesh I wanted to fade.

Check it out here if you’d like:

My questions really come from fading and the translucent material as well as requiring every material to have a translucent version vs an opaque one to switch between.

As it stands right now I keep having the translucent material losing much of the shadowing on it but I didn’t see an option for it under the materials, it looks like this:


As you can see the shadows seem to disappear on the second image, this happens when I switch the material out to the translucent one. Is there a setting I’m missing? I don’t seem to see one right now but I might just be missing it which would allow the translucent to keep its shadows.

And second question is this a good method for creation of fading? Requiring two materials for each mesh you want to fade or is there a better way I am some how missing?