Look somewhere and enviroment changes

You know what i’m talking about, the classic movie trick, or hell even sometimes in games, you look at the hallway and realize it’s a dead end, you turn around and suddenly there’s a wall behind you.

How would i go around doing that? i know how to do the wall thing, but making it so when looking at a specific location triggers a change?

Place a collision volume and trace against it.


  • player gets to the wall, spawn / activate a collision volume behind them, start forward tracing
  • when the trace hits the above-mentioned volume, you know the player is looking away from the wall behind them
  • remove the wall the player is not seeing and replace it with spookiness of your choice or any other scenario that comes to mind

Alternatively, use dot product to ensure the player is not facing the wall once they’ve reached it.

Yeah, that’s the problem, i’m a bit new when it comes to tracing so i don’t really know HOW to make it hit the sweet spot.

Consider the following:

Here’s an actor with a DeadEndWall (static mesh), TriggerVolume (box collision) and a SweetSpot (sphere collision):

The latter’s collision is set to block visibility because we want to trace against it later on:

And the script in the Wall:

We start interacting with it when the player enters the TriggerVolume. We then trace from the camera forward - so where the player is aiming. If that trace is blocked by the SweetSpot, we spawn something 500 in front of the wall (hopefully far enough that it ends up behind the player). And then close the gate so we don’t spawn more objects.

Image from Gyazo


This is by no means a complete system but it may give you an idea of how to approach creating a feature like this. And there are many, many ways of accomplishing that, surely. My aims here was to make it somewhat modular so you can plop more than one of those anywhere and it would just work.

you look at the hallway and realize
it’s a dead end, you turn around and
suddenly there’s a wall behind you.

I think I misunderstood it somehow, my bad. In this case it’d would be a matter of the player entering a collision volume that spawns something behind them.

but making it so when looking at a
specific location triggers a change?

You can trace, when the trace hits the sweet spot, you replace whatever is behind the player. Ideally, you combine the 2. You start tracing when the player is in a specific volume.

And to visualise it:

Image from Gyazo

Thank you so much! this is exactly what i was hoping to achieve, you’re a real life saver.